ZQuest Classic Coverage Report


Directory: src/
File: src/zc/hero.cpp
Date: 2024-09-12 06:20:38
Exec Total Coverage
Lines: 14724 20638 71.3%
Functions: 318 387 82.2%
Branches: 12881 22725 56.7%

Line Branch Exec Source
1 #include <cstring>
2 #include <set>
3 #include <stdio.h>
4
5 #include "base/qrs.h"
6 #include "base/dmap.h"
7 #include "zc/hero.h"
8 #include "zc/guys.h"
9 #include "subscr.h"
10 #include "zc/replay.h"
11 #include "zc/zc_ffc.h"
12 #include "zc/zc_subscr.h"
13 #include "zc/decorations.h"
14 #include "gamedata.h"
15 #include "zc/zc_custom.h"
16 #include "zc/title.h"
17 #include "zc/ffscript.h"
18 #include "drawing.h"
19 #include "zc/combos.h"
20 #include "base/zc_math.h"
21 #include "user_object.h"
22 #include "slopes.h"
23 #include "zinfo.h"
24 #include "base/misctypes.h"
25 #include "music_playback.h"
26
27 extern HeroClass Hero;
28 extern ZModule zcm;
29 extern zcmodule moduledata;
30 extern refInfo playerScriptData;
31 #include "zscriptversion.h"
32 #include "particles.h"
33 #include <fmt/format.h>
34 #include "zc/render.h"
35
36 extern refInfo *ri; //= NULL;
37 extern int32_t(*stack)[MAX_SCRIPT_REGISTERS];
38 extern portal mirror_portal;
39 using std::set;
40
41 extern int32_t skipcont;
42
43 extern int32_t draw_screen_clip_rect_x1;
44 extern int32_t draw_screen_clip_rect_x2;
45 extern int32_t draw_screen_clip_rect_y1;
46 extern int32_t draw_screen_clip_rect_y2;
47
48 int32_t hero_count = -1;
49 int32_t hero_animation_speed = 1; //lower is faster animation
50 static int32_t z3step = 2;
51 356 static zfix hero_newstep(1.5);
52 356 static zfix hero_newstep_diag(1.5);
53 bool did_scripta=false;
54 bool did_scriptb=false;
55 bool did_scriptl=false;
56 byte lshift = 0;
57 int32_t dowpn = -1;
58 int32_t directItemA = -1;
59 int32_t directItemB = -1;
60 int32_t directItemX = -1;
61 int32_t directItemY = -1;
62 int32_t directWpn = -1;
63 int32_t whistleitem=-1;
64 extern int32_t script_hero_cset;
65
66 void playLevelMusic();
67
68 extern particle_list particles;
69
70 byte lsteps[8] = { 1, 1, 2, 1, 1, 2, 1, 1 };
71
72 #define CANFORCEFACEUP (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0 && dir!=up && (action==walking || action==none))
73 #define NO_GRIDLOCK (get_qr(qr_DISABLE_4WAY_GRIDLOCK)||get_qr(qr_NEW_HERO_MOVEMENT2))
74 #define SWITCHBLOCK_STATE (switchblock_z<0?switchblock_z:(switchblock_z+z+fakez < 0 ? zslongToFix(2147483647) : switchblock_z+z+fakez))
75 #define FIXED_Z3_ANIMATION ((zinit.heroAnimationStyle==las_zelda3||zinit.heroAnimationStyle==las_zelda3slow)&&!get_qr(qr_BROKEN_Z3_ANIMATION))
76
77 47 bool item_error()
78 {
79
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 39 times.
47 if(QMisc.miscsfx[sfxERROR])
80 8 sfx(QMisc.miscsfx[sfxERROR]);
81 47 return false;
82 }
83 5353567 static inline bool on_sideview_slope(int32_t x, int32_t y, int32_t oldx, int32_t oldy)
84 {
85
2/2
✓ Branch 0 taken 1211 times.
✓ Branch 1 taken 5352356 times.
5353567 if(check_new_slope(x, y+0.0001_zf, 16, 16, oldx, oldy, false, true) < 0) return true;
86 5352356 return false;
87 5353567 }
88
89 12097610 static inline bool platform_fallthrough(bool doslopecheck = true)
90 {
91
2/2
✓ Branch 0 taken 10312360 times.
✓ Branch 1 taken 1785250 times.
12097610 if (!getInput(btnDown, false, get_qr(qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0))
92 10312360 return false;
93
94
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1785250 times.
1785250 if (get_qr(qr_DOWN_FALL_THROUGH_SIDEVIEW_PLATFORMS))
95 return true;
96
97
3/4
✓ Branch 0 taken 26318 times.
✓ Branch 1 taken 1758932 times.
✓ Branch 2 taken 26318 times.
✗ Branch 3 not taken.
1785250 if (Hero.jumping < 0 && get_qr(qr_DOWNJUMP_FALL_THROUGH_SIDEVIEW_PLATFORMS))
98 return true;
99
100
7/8
✓ Branch 0 taken 1785250 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1056 times.
✓ Branch 3 taken 1784194 times.
✓ Branch 4 taken 1784123 times.
✓ Branch 5 taken 71 times.
✓ Branch 6 taken 155 times.
✓ Branch 7 taken 1785095 times.
3569444 if (doslopecheck && !on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)))
101 155 return true;
102
103 1785095 return false;
104 12097610 }
105
106 4938 static inline bool on_sideview_solid(zfix x, zfix y, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
107 {
108
3/4
✓ Branch 0 taken 4938 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3369 times.
✓ Branch 3 taken 1569 times.
4938 if(slopesmisc != 1 && check_slope(x, y + 0.0001_zf, 16, 16, (slopesmisc == 3), true) < 0) return true;
109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3369 times.
3369 if(slopesmisc == 2) return false;
110
3/4
✓ Branch 0 taken 2349 times.
✓ Branch 1 taken 1020 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2349 times.
3369 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
111
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2349 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2349 if (y>=160_zf && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
112
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2349 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2349 if (platform_fallthrough() && !ignoreFallthrough) return false;
113
2/4
✓ Branch 0 taken 2349 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2349 times.
✗ Branch 3 not taken.
2349 if(slopesmisc != 1 && check_slope(x, y + 0.0001_zf, 16, 16, false, true) < 0) return true;
114
4/6
✓ Branch 0 taken 2226 times.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2349 times.
2472 if (y.getInt() % 16 ==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
115 return true;
116 2349 return false;
117 4938 }
118
119 static inline bool on_sideview_solid_oldpos(zfix x, zfix y, zfix oldx, zfix oldy, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
120 {
121 if(slopesmisc != 1 && check_new_slope(x, y+0.0001_zf, 16, 16, oldx, oldy, (slopesmisc == 3), true) < 0) return true;
122 if(slopesmisc == 2) return false;
123 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
124 if (y>=160_zf && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
125 if (platform_fallthrough() && !ignoreFallthrough) return false;
126 if (slopesmisc != 1 && check_new_slope(x, y + 0.0001_zf, 16, 16, oldx, oldy, false, true) < 0) return true;
127 if (y.getInt()%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
128 return true;
129 return false;
130 }
131
132 16091963 static inline bool on_sideview_solid_oldpos(sprite* obj, bool ignoreFallthrough = false, int32_t slopesmisc = 0, zfix xofs = 0, zfix yofs = 0)
133 {
134 16091963 zfix rx = obj->x+obj->hxofs+obj->sxofs+xofs, ry = obj->y+obj->hyofs+obj->syofs+yofs,
135 16091963 rw = obj->hit_width+obj->sxsz_ofs, rh = obj->hit_height+obj->sysz_ofs,
136 16091963 orx = obj->old_x+obj->hxofs+obj->sxofs, ory = obj->old_y+obj->hyofs+obj->syofs,
137 16091963 x = obj->x+xofs, y = obj->y+yofs;
138
4/4
✓ Branch 0 taken 1664886 times.
✓ Branch 1 taken 14427077 times.
✓ Branch 2 taken 1644840 times.
✓ Branch 3 taken 20046 times.
16091963 if(slopesmisc != 1 && check_new_slope(rx, ry+0.0001_zf, rw, rh, orx, ory, (slopesmisc == 3), true, obj->slopeid) < 0) return true;
139
2/2
✓ Branch 0 taken 126943 times.
✓ Branch 1 taken 15944974 times.
16071917 if(slopesmisc == 2) return false;
140
4/4
✓ Branch 0 taken 12424337 times.
✓ Branch 1 taken 3520637 times.
✓ Branch 2 taken 328178 times.
✓ Branch 3 taken 12096159 times.
15944974 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
141
6/6
✓ Branch 0 taken 100818 times.
✓ Branch 1 taken 11995341 times.
✓ Branch 2 taken 6083 times.
✓ Branch 3 taken 94735 times.
✓ Branch 4 taken 5185 times.
✓ Branch 5 taken 898 times.
12096159 if (y>=160_zf && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
142
3/4
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 12095106 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 155 times.
12095261 if (platform_fallthrough() && !ignoreFallthrough) return false;
143
3/4
✓ Branch 0 taken 703733 times.
✓ Branch 1 taken 11391373 times.
✓ Branch 2 taken 703733 times.
✗ Branch 3 not taken.
12095106 if (slopesmisc != 1 && check_new_slope(rx, ry+0.0001_zf, rw, rh, orx, ory, false, true, obj->slopeid) < 0) return true;
144
4/6
✓ Branch 0 taken 9025997 times.
✓ Branch 1 taken 3069109 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3069109 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12095106 times.
15164215 if (y.getInt()%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
145 return true;
146 12095106 return false;
147 16091963 }
148
149 107769 static inline bool no_plat_action()
150 {
151
5/8
✓ Branch 0 taken 107769 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107471 times.
✓ Branch 3 taken 298 times.
✓ Branch 4 taken 107471 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 107471 times.
107769 if(Hero.fallclk || Hero.drownclk || toogam || Hero.getOnSideviewLadder())
152 298 return true;
153
2/2
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 107030 times.
107471 switch(Hero.action)
154 {
155 case freeze: case rafting: case inwind: case scrolling: case won: case hopping:
156 case climbcovertop: case climbcoverbottom: case dying: case drowning:
157 case falling: case lavadrowning: case sideswimfreeze: case sidedrowning:
158 441 return true;
159 }
160 107030 return false;
161 107769 }
162 89687 bool HeroClass::on_ffc_platform(ffcdata const& ffc, bool old)
163 {
164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89687 times.
89687 if(no_plat_action())
165 return false;
166
2/2
✓ Branch 0 taken 49841 times.
✓ Branch 1 taken 39846 times.
89687 if(!get_qr(qr_MULTI_PLATFORM_FFC))
167 {
168
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39846 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39846 if(platform_ffc && &ffc != platform_ffc)
169 return false;
170 39846 platform_ffc = nullptr;
171 39846 }
172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89687 times.
89687 if(sideview_mode())
173 {
174 if((ffc.flags & (ffc_solid|ffc_platform|ffc_changer)) != (ffc_solid|ffc_platform))
175 return false;
176 zfix fx = old ? ffc.old_x : ffc.x, fy = old ? ffc.old_y : ffc.y;
177 static const zfix tol = 0.5_zf;
178 if((y+16-fy).getAbs() > tol)
179 return false;
180 if(fx > x+12)
181 return false;
182 if(fx+ffc.hit_width <= x+4)
183 return false;
184 }
185 else
186 {
187
2/2
✓ Branch 0 taken 89498 times.
✓ Branch 1 taken 189 times.
89687 if((ffc.flags & (ffc_platform|ffc_changer)) != ffc_platform)
188 89498 return false;
189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(z)
190 return false;
191 static const int tol = 3;
192
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 188 times.
189 if(!(old
193 189 ? ffc.collide_old(x + 8-tol, y + (bigHitbox ? 8 : 12), tol*2, tol*2)
194 : ffc.collide(x + 8-tol, y + (bigHitbox ? 8 : 12)-tol, tol*2, tol*2)))
195 188 return false;
196 }
197 1 platform_ffc = &ffc;
198 1 return true;
199 89687 }
200 18082 bool HeroClass::on_ffc_platform()
201 {
202
2/2
✓ Branch 0 taken 739 times.
✓ Branch 1 taken 17343 times.
18082 if(no_plat_action())
203 739 return false;
204
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17343 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17343 if(platform_ffc && on_ffc_platform(*platform_ffc,false))
205 return true;
206 17343 word c = tmpscr->numFFC();
207
2/2
✓ Branch 0 taken 89498 times.
✓ Branch 1 taken 17343 times.
106841 for(word i=0; i<c; i++)
208 {
209 89498 ffcdata& ffc = tmpscr->ffcs[i];
210
1/2
✓ Branch 0 taken 89498 times.
✗ Branch 1 not taken.
89498 if(on_ffc_platform(ffc,false))
211 return true;
212 89498 }
213 17343 return false;
214 18082 }
215
216 14619214 void HeroClass::check_platform_ffc()
217 {
218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14619214 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14619214 if(platform_ffc && !on_ffc_platform(*platform_ffc,false))
219 {
220 clear_platform_ffc();
221 on_ffc_platform();
222 }
223 14619214 }
224 36775 void HeroClass::clear_platform_ffc()
225 {
226 36775 platform_ffc = nullptr;
227 36775 }
228
229 2583 void HeroClass::snap_platform()
230 {
231
2/2
✓ Branch 0 taken 1515 times.
✓ Branch 1 taken 1068 times.
2583 if(check_new_slope(x, y+1, 16, 16, old_x, old_y, false, true) < 0)
232 1515 return;
233
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1068 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1068 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN))
234 {
235 y = 160;
236 return;
237 }
238
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1035 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 18 times.
1068 if (!(_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)))
239 18 return;
240 1050 movexy(0,1,false,true,false,false);
241 2583 }
242
243
244 40768794 bool usingActiveShield(int32_t itmid)
245 {
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40768794 times.
40768794 if(Hero.shieldjinxclk) return false;
247
2/2
✓ Branch 0 taken 35186575 times.
✓ Branch 1 taken 5582219 times.
40768794 switch(Hero.action) //filter allowed actions
248 {
249 case none: case walking: case rafting:
250 case gothit: case swimhit:
251 35186575 break;
252 5582219 default: return false;
253 }
254
4/4
✓ Branch 0 taken 14023 times.
✓ Branch 1 taken 35172552 times.
✓ Branch 2 taken 6009 times.
✓ Branch 3 taken 8014 times.
35186575 if(Hero.lift_wpn && (Hero.liftflags&LIFTFL_DIS_SHIELD)) return false;
255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35178561 times.
35178561 if(itmid < 0)
256
1/2
✓ Branch 0 taken 35178561 times.
✗ Branch 1 not taken.
35178561 itmid = (Hero.active_shield_id < 0
257 35178561 ? current_item_id(itype_shield,true,true) : Hero.active_shield_id);
258
2/2
✓ Branch 0 taken 31186248 times.
✓ Branch 1 taken 3992313 times.
35178561 if(itmid < 0) return false;
259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31186248 times.
31186248 if(item_disabled(itmid)) return false;
260
1/2
✓ Branch 0 taken 31186248 times.
✗ Branch 1 not taken.
31186248 if(!checkitem_jinx(itmid)) return false;
261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31186248 times.
31186248 if(!(itemsbuf[itmid].flags & item_flag9)) return false;
262 if(!isItmPressed(itmid)) return false;
263 return (checkbunny(itmid) && checkmagiccost(itmid));
264 40768794 }
265 4397857 int32_t getCurrentShield(bool requireActive)
266 {
267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4397857 times.
4397857 if(Hero.shieldjinxclk) return -1;
268
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4397857 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4397857 if(Hero.active_shield_id > -1 && usingActiveShield(Hero.active_shield_id))
269 return Hero.active_shield_id;
270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4397857 times.
4397857 if(!requireActive) return current_item_id(itype_shield,false,true);
271 return -1;
272 4397857 }
273 588330 int32_t getCurrentActiveShield()
274 {
275 588330 int32_t id = Hero.active_shield_id;
276
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 588330 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
588330 if(id > -1 && usingActiveShield(id))
277 return id;
278 588330 return -1;
279 588330 }
280 14168568 int32_t refreshActiveShield()
281 {
282 14168568 int32_t id = -1;
283
2/2
✓ Branch 0 taken 13877288 times.
✓ Branch 1 taken 291280 times.
14168568 if(DrunkcBbtn())
284 {
285
2/2
✓ Branch 0 taken 289369 times.
✓ Branch 1 taken 1911 times.
291280 itemdata const& dat = itemsbuf[NEG_OR_MASK(Bwpn,0xFFF)];
286
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 291280 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
291280 if(dat.family == itype_shield && (dat.flags & item_flag9))
287 {
288 id = NEG_OR_MASK(Bwpn,0xFFF);
289 }
290 291280 }
291
3/4
✓ Branch 0 taken 14168568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12939530 times.
✓ Branch 3 taken 1229038 times.
14168568 if(id < 0 && DrunkcAbtn())
292 {
293
2/2
✓ Branch 0 taken 1092490 times.
✓ Branch 1 taken 136548 times.
1229038 itemdata const& dat = itemsbuf[NEG_OR_MASK(Awpn,0xFFF)];
294
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1229038 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1229038 if(dat.family == itype_shield && (dat.flags & item_flag9))
295 {
296 id = NEG_OR_MASK(Awpn,0xFFF);
297 }
298 1229038 }
299
3/4
✓ Branch 0 taken 14168568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14156011 times.
✓ Branch 3 taken 12557 times.
14168568 if(id < 0 && DrunkcEx1btn())
300 {
301
2/2
✓ Branch 0 taken 1997 times.
✓ Branch 1 taken 10560 times.
12557 itemdata const& dat = itemsbuf[NEG_OR_MASK(Xwpn,0xFFF)];
302
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12557 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12557 if(dat.family == itype_shield && (dat.flags & item_flag9))
303 {
304 id = NEG_OR_MASK(Xwpn,0xFFF);
305 }
306 12557 }
307
3/4
✓ Branch 0 taken 14168568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14165861 times.
✓ Branch 3 taken 2707 times.
14168568 if(id < 0 && DrunkcEx2btn())
308 {
309
2/2
✓ Branch 0 taken 2471 times.
✓ Branch 1 taken 236 times.
2707 itemdata const& dat = itemsbuf[NEG_OR_MASK(Ywpn,0xFFF)];
310
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2707 if(dat.family == itype_shield && (dat.flags & item_flag9))
311 {
312 id = NEG_OR_MASK(Ywpn,0xFFF);
313 }
314 2707 }
315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14168568 times.
14168568 if(!usingActiveShield(id))
316 14168568 return -1;
317 return id;
318 14168568 }
319 static bool is_immobile()
320 {
321 if(!get_qr(qr_NEW_HERO_MOVEMENT))
322 return false;
323 zfix rate(Hero.steprate);
324 int32_t shieldid = getCurrentActiveShield();
325 if(shieldid > -1)
326 {
327 itemdata const& shield = itemsbuf[shieldid];
328 if(shield.flags & item_flag10) //Change Speed flag
329 {
330 zfix perc = shield.misc7;
331 perc /= 100;
332 if(perc < 0)
333 perc = (perc*-1)+1;
334 rate = (rate * perc) + shield.misc8;
335 }
336 }
337 return rate != 0;
338 }
339
340 28517033 bool nomove_action(int action)
341 {
342
2/2
✓ Branch 0 taken 27311955 times.
✓ Branch 1 taken 1205078 times.
28517033 switch(action)
343 {
344 case gothit:
345 case drowning:
346 case lavadrowning:
347 case sidedrowning:
348 case falling:
349 case freeze:
350 case sideswimfreeze:
351 case scrolling:
352 case casting:
353 case sideswimcasting:
354 case landhold1:
355 case landhold2:
356 case waterhold1:
357 case waterhold2:
358 case sidewaterhold1:
359 case sidewaterhold2:
360 case hopping:
361 case inwind:
362 1205078 return true;
363 }
364 27311955 return false;
365 28517033 }
366
367 14509200 bool HeroClass::isStanding(bool forJump)
368 {
369
3/4
✓ Branch 0 taken 14477276 times.
✓ Branch 1 taken 31924 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14477276 times.
14509200 if(z || fakez) return false;
370
3/4
✓ Branch 0 taken 262509 times.
✓ Branch 1 taken 14214767 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 129192 times.
14606468 if(isSideViewHero() && !on_sideview_solid_oldpos(this)
371
4/6
✓ Branch 0 taken 129192 times.
✓ Branch 1 taken 133317 times.
✓ Branch 2 taken 129192 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 129192 times.
✗ Branch 5 not taken.
262509 && !ladderx && !laddery && !getOnSideviewLadder())
372 129192 return false;
373
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 14348048 times.
14348084 if(hoverclk) return false;
374
2/2
✓ Branch 0 taken 600178 times.
✓ Branch 1 taken 13747870 times.
14348048 if(nomove_action(action)) return false;
375 13747870 int32_t val = check_pitslide();
376
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 13747833 times.
13747870 if(val == -2) return false;
377
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 13747548 times.
13747833 if(val == -1) return true;
378 285 return forJump;
379 14509200 }
380 821635 bool HeroClass::isLifting()
381 {
382
2/2
✓ Branch 0 taken 11972 times.
✓ Branch 1 taken 809663 times.
821635 if(lift_wpn) return true;
383 809663 return false;
384 821635 }
385 68 void HeroClass::set_liftflags(int liftid)
386 {
387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(unsigned(liftid) >= MAXITEMS)
388 return;
389 68 itemdata const& itm = itemsbuf[liftid];
390
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 SETFLAG(liftflags, LIFTFL_DIS_SWIMMING, !(itm.flags & item_flag2));
391
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 39 times.
68 SETFLAG(liftflags, LIFTFL_DIS_SHIELD, itm.flags & item_flag3);
392
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 39 times.
68 SETFLAG(liftflags, LIFTFL_DIS_ITEMS, itm.flags & item_flag4);
393 68 }
394
395 521510 void HeroClass::set_respawn_point(bool setwarp)
396 {
397 521510 zfix oldx = x, oldy = y;
398
2/2
✓ Branch 0 taken 34559 times.
✓ Branch 1 taken 486951 times.
521510 if (replay_version_check(17))
399 {
400 486951 x = vbound(x,0_zf,240_zf);
401 486951 y = vbound(y,0_zf,160_zf);
402 486951 }
403
404
2/2
✓ Branch 0 taken 503578 times.
✓ Branch 1 taken 17932 times.
521510 if(setwarp)
405 {
406 17932 warpx = x;
407 17932 warpy = y;
408 17932 raftwarpx = x;
409 17932 raftwarpy = y;
410 17932 }
411 521510 do
412 {
413
2/2
✓ Branch 0 taken 44179 times.
✓ Branch 1 taken 477331 times.
521510 if(!get_qr(qr_OLD_RESPAWN_POINTS))
414 {
415
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 477212 times.
477331 if(currscr >= 0x80) break;
416 477212 bool is_safe = true;
417
2/2
✓ Branch 0 taken 412977 times.
✓ Branch 1 taken 64235 times.
477212 switch(action)
418 {
419 case none: case walking:
420 412977 break;
421 default:
422 64235 is_safe = false;
423 64235 }
424
2/2
✓ Branch 0 taken 412977 times.
✓ Branch 1 taken 64235 times.
477212 if(!is_safe) break; //unsafe action
425
5/6
✓ Branch 0 taken 410097 times.
✓ Branch 1 taken 2880 times.
✓ Branch 2 taken 410097 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 410078 times.
412977 if(z > 0 || fakez > 0 || hoverclk) break; //in air
426
4/4
✓ Branch 0 taken 4938 times.
✓ Branch 1 taken 405140 times.
✓ Branch 2 taken 2589 times.
✓ Branch 3 taken 2349 times.
410078 if(sideview_mode() && !on_sideview_solid(x,y,true)) break; //in air sideview
427
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 407576 times.
407729 if(check_pitslide(true) != -1) break; //On a pit
428
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 407565 times.
407576 if (ladderx+laddery) break; //on the ladder
429
430 { //Check water
431 407565 int32_t water = 0;
432 407565 int32_t types[4] = {0};
433 407565 int32_t x1 = x+4, x2 = x+11,
434 407565 y1 = y+9, y2 = y+15;
435
1/2
✓ Branch 0 taken 407565 times.
✗ Branch 1 not taken.
407565 if (get_qr(qr_SMARTER_WATER))
436 {
437
4/4
✓ Branch 0 taken 1905 times.
✓ Branch 1 taken 405660 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 249 times.
407827 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
438
2/2
✓ Branch 0 taken 1157 times.
✓ Branch 1 taken 748 times.
1905 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
439
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 895 times.
1157 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
440 262 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
441 407565 }
442 else
443 {
444 types[0] = COMBOTYPE(x1,y1);
445
446 if(MAPFFCOMBO(x1,y1))
447 types[0] = FFCOMBOTYPE(x1,y1);
448
449 types[1] = COMBOTYPE(x1,y2);
450
451 if(MAPFFCOMBO(x1,y2))
452 types[1] = FFCOMBOTYPE(x1,y2);
453
454 types[2] = COMBOTYPE(x2,y1);
455
456 if(MAPFFCOMBO(x2,y1))
457 types[2] = FFCOMBOTYPE(x2,y1);
458
459 types[3] = COMBOTYPE(x2,y2);
460
461 if(MAPFFCOMBO(x2,y2))
462 types[3] = FFCOMBOTYPE(x2,y2);
463
464 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
465 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
466 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
467
468 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
469 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
470 water = typec;
471 }
472
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 407316 times.
407565 if(water > 0)
473 249 break;
474 } //End check water
475
476 2036580 int poses[4] = {
477 407316 COMBOPOS(x,y+(bigHitbox?0:8)),
478 407316 COMBOPOS(x,y+15),
479 407316 COMBOPOS(x+15,y+(bigHitbox?0:8)),
480 407316 COMBOPOS(x+15,y+15)
481 };
482
2/2
✓ Branch 0 taken 364176 times.
✓ Branch 1 taken 1508763 times.
1872939 for(auto pos : poses)
483 {
484
2/2
✓ Branch 0 taken 1465623 times.
✓ Branch 1 taken 43140 times.
1508763 if(HASFLAG_ANY(mfUNSAFEGROUND, pos)) //"Unsafe Ground" flag touching the player
485 {
486 43140 is_safe = false;
487 43140 break;
488 }
489 }
490
2/2
✓ Branch 0 taken 364176 times.
✓ Branch 1 taken 43140 times.
407316 if(!is_safe) break;
491 364176 }
492 408355 respawn_x = x;
493 408355 respawn_y = y;
494 408355 respawn_scr = currscr;
495 408355 respawn_dmap = currdmap;
496 408355 }
497 while(false); //run once, but 'break' works
498
499 521510 x = oldx;
500 521510 y = oldy;
501 521510 }
502
503 355708 void HeroClass::clear_ice()
504 {
505 355708 ice_vx = ice_vy = 0;
506 355708 ice_entry_count = ice_entry_mcount = 0;
507 355708 ice_combo = 0;
508 355708 sliding = 0;
509 355708 }
510
511 147 void HeroClass::go_respawn_point()
512 {
513 147 x = respawn_x;
514 147 y = respawn_y;
515 147 clear_ice();
516 147 handle_portal_prox(&mirror_portal);
517
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 portals.forEach([&](sprite& p)
518 {
519 handle_portal_prox((portal*)&p);
520 return false;
521 });
522 147 warpx=x;
523 147 warpy=y;
524 147 raftwarpx = x;
525 147 raftwarpy = y;
526 147 trySideviewLadder(); //Cling to ladder automatically
527
528
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 68 times.
147 if(get_qr(qr_OLD_RESPAWN_POINTS))
529 68 return; //No cross-screen return
530
531
2/4
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79 times.
79 if(currdmap != respawn_dmap || currscr != respawn_scr)
532 {
533 FFCore.warp_player(wtIWARP, respawn_dmap, respawn_scr-DMaps[currdmap].xoff,
534 -1, -1, 0, 0, warpFlagNOSTEPFORWARD, -1);
535 }
536 147 }
537
538 33330 void HeroClass::trySideviewLadder()
539 {
540
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33330 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33330 if(canSideviewLadder() && !on_sideview_solid_oldpos(this))
541 setOnSideviewLadder(true);
542 33330 }
543
544 65735540 bool HeroClass::can_pitfall(bool ignore_hover)
545 {
546 65735540 return !(
547 65735540 isSideViewGravity()
548
2/2
✓ Branch 0 taken 65132460 times.
✓ Branch 1 taken 603080 times.
65735540 || action==rafting
549
7/8
✓ Branch 0 taken 64792575 times.
✓ Branch 1 taken 339885 times.
✓ Branch 2 taken 64755046 times.
✓ Branch 3 taken 37529 times.
✓ Branch 4 taken 64755046 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64753875 times.
✓ Branch 7 taken 1171 times.
65132460 || z>0 || fakez>0 || fall<0 || fakefall<0
550
3/4
✓ Branch 0 taken 64753875 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 64753805 times.
64753875 || (hoverclk && !ignore_hover)
551
6/6
✓ Branch 0 taken 64723623 times.
✓ Branch 1 taken 30252 times.
✓ Branch 2 taken 64719636 times.
✓ Branch 3 taken 3987 times.
✓ Branch 4 taken 64684808 times.
✓ Branch 5 taken 34828 times.
64753875 || inlikelike || inwallm || pull_hero || toogam
552
6/6
✓ Branch 0 taken 64598276 times.
✓ Branch 1 taken 86532 times.
✓ Branch 2 taken 63960343 times.
✓ Branch 3 taken 637933 times.
✓ Branch 4 taken 63960063 times.
✓ Branch 5 taken 280 times.
64684808 || (ladderx||laddery) || getOnSideviewLadder()
553
3/4
✓ Branch 0 taken 63960063 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63947701 times.
✓ Branch 3 taken 12362 times.
63960063 || drownclk || !(moveflags & move_can_pitfall)
554
2/2
✓ Branch 0 taken 63946958 times.
✓ Branch 1 taken 743 times.
63947701 || platform_ffc);
555 }
556
557 8342185 int32_t HeroClass::DrunkClock()
558 {
559 8342185 return drunkclk;
560 }
561 1 void HeroClass::setDrunkClock(int32_t newdrunkclk)
562 {
563 1 drunkclk=newdrunkclk;
564 1 }
565
566 440770 int32_t HeroClass::StunClock()
567 {
568 440770 return lstunclock;
569 }
570 290 void HeroClass::setStunClock(int32_t v)
571 {
572 290 lstunclock=v;
573 290 }
574
575 3108872234 int32_t HeroClass::BunnyClock()
576 {
577 3108872234 return lbunnyclock;
578 }
579 void HeroClass::setBunnyClock(int32_t v)
580 {
581 lbunnyclock=v;
582 }
583
584
13/26
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 356 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 356 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 356 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 356 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 356 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 356 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 356 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 356 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 356 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 356 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 356 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 356 times.
✗ Branch 25 not taken.
712 HeroClass::HeroClass() : sprite()
585 356 {
586 356 lift_wpn = nullptr;
587
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 init();
588 356 }
589
590 //2.6
591
592 //Stop the subscreen from falling. -Z
593
594 1368 bool HeroClass::stopSubscreenFalling(){
595 1368 return preventsubscreenfalling;
596 }
597
598 void HeroClass::stopSubscreenFalling(bool v){
599 preventsubscreenfalling = v;
600 }
601
602 14170183 void HeroClass::ClearhitHeroUIDs()
603 { //Why the flidd doesn't this work?! Clearing this to 0 in a way that doesn't demolish script access is impossible. -Z
604 //All I want, is to clear it at the end of a frame, or at the start of a frame, so that if it changes to non-0
605 //that a script can read it before Waitdraw(). --I want it to go stale at the end of a frame.
606 //I suppose I will need to do this inside the script engine, and not the game_loop() ? -Z
607 //THis started out as a simple clear to 0 of lastHitBy[n], but that did not work:
608 //I added the second element to this, so that I could store the frame on which the hit is recorded, and
609 //clear it on the next frame, but that had the SAME outcome.
610 //Where and how can I clear a value at the end of every frame, so that:
611 // 1. If set by internal mecanics, it has its value that you can read by script, before waitdraw--this part works at present.
612 // 2. FFCs can read it before Waitframe. --same.
613 // 3. After Waitframe(), it is wiped by the ZC Engine to 0. --I cannot get this to happen without breaking 1 and 2.
614
2/2
✓ Branch 0 taken 240893111 times.
✓ Branch 1 taken 14170183 times.
255063294 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ )
615 {
616 /*
617 if ( lastHitBy[q][1] == (frame-1) ) //Verify if this is needed at all now.
618 {
619 //Z_scripterrlog("frame is: %d\n", frame);
620 //Z_scripterrlog("Player->HitBy frame is: %d\n", lastHitBy[q][1]);
621 lastHitBy[q][0] = 0;
622 }
623 */
624 240893111 lastHitBy[q][0] = 0;
625 240893111 }
626 14170183 }
627
628 76582 void HeroClass::sethitHeroUID(int32_t type, int32_t screen_index)
629 {
630 76582 lastHitBy[type][0] = screen_index;
631 76582 }
632
633 3244 int32_t HeroClass::gethitHeroUID(int32_t type)
634 {
635 3244 return lastHitBy[type][0];
636 }
637
638 void HeroClass::set_defence(int32_t type, int32_t v)
639 {
640 defence[type] = v;
641 }
642
643 int32_t HeroClass::get_defence(int32_t type)
644 {
645 return defence[type];
646 }
647
648
649 //Set Hero;s hurt sfx
650 277115 void HeroClass::setHurtSFX(int32_t sfx)
651 {
652 277115 QMisc.miscsfx[sfxHURTPLAYER] = sfx;
653 277115 }
654 15444 int32_t HeroClass::getHurtSFX()
655 {
656 15444 return QMisc.miscsfx[sfxHURTPLAYER];
657 }
658
659 bool HeroClass::getDiagMove()
660 {
661 return diagonalMovement;
662 }
663 1063 void HeroClass::setDiagMove(bool newdiag)
664 {
665 1063 diagonalMovement=newdiag;
666 1063 }
667 271788 bool HeroClass::getBigHitbox()
668 {
669 271788 return bigHitbox;
670 }
671 2503 void HeroClass::setBigHitbox(bool newbigHitbox)
672 {
673 2503 bigHitbox=newbigHitbox;
674 2503 syofs = bigHitbox?0:8;
675 2503 sysz_ofs = bigHitbox?0:-8;
676 2503 }
677 6371 int32_t HeroClass::getStepRate()
678 {
679 6371 return steprate;
680 }
681 947 void HeroClass::setStepRate(int32_t newrate)
682 {
683 947 steprate = newrate;
684 947 }
685 int32_t HeroClass::getSwimUpRate()
686 {
687 return game->get_sideswim_up();
688 }
689 void HeroClass::setSwimUpRate(int32_t newrate)
690 {
691 game->set_sideswim_up(newrate);
692 }
693 int32_t HeroClass::getSwimSideRate()
694 {
695 return game->get_sideswim_side();
696 }
697 void HeroClass::setSwimSideRate(int32_t newrate)
698 {
699 game->set_sideswim_side(newrate);
700 }
701 int32_t HeroClass::getSwimDownRate()
702 {
703 return game->get_sideswim_down();
704 }
705 void HeroClass::setSwimDownRate(int32_t newrate)
706 {
707 game->set_sideswim_down(newrate);
708 }
709
710
711 10411310 void HeroClass::herostep()
712 {
713
2/2
✓ Branch 0 taken 9760249 times.
✓ Branch 1 taken 651061 times.
10411310 lstep = lstep<((zinit.heroAnimationStyle==las_bszelda)?27:11) ? lstep+1 : 0;
714 //need to run all global/hero/dmap scripts here?
715 10411310 }
716
717 142451 bool is_moving()
718 {
719
6/6
✓ Branch 0 taken 110147 times.
✓ Branch 1 taken 32304 times.
✓ Branch 2 taken 82023 times.
✓ Branch 3 taken 28124 times.
✓ Branch 4 taken 32573 times.
✓ Branch 5 taken 49450 times.
142451 return DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight();
720 }
721
722 // called by ALLOFF()
723 35854 void HeroClass::resetflags(bool all)
724 {
725 35854 refilling=REFILL_NONE;
726 35854 inwallm=false;
727 35854 inlikelike=blowcnt=whirlwind=specialcave=hclk=fairyclk=refill_why=didstuff=0;
728 35854 usecounts.clear();
729
730
4/4
✓ Branch 0 taken 35773 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 372 times.
✓ Branch 3 taken 35401 times.
35854 if(swordclk>0 || all)
731 {
732 453 swordclk=0;
733 453 verifyAWpn();
734 453 }
735
4/4
✓ Branch 0 taken 35836 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 372 times.
✓ Branch 3 taken 35464 times.
35854 if(itemclk>0 || all)
736 390 itemclk=0;
737
3/4
✓ Branch 0 taken 35854 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 372 times.
✓ Branch 3 taken 35482 times.
35854 if(shieldjinxclk>0 || all)
738 372 shieldjinxclk=0;
739
740
2/2
✓ Branch 0 taken 35482 times.
✓ Branch 1 taken 372 times.
35854 if(all)
741 {
742 372 DivineProtectionShieldClk=0;
743
744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 372 times.
372 if(div_prot_item != -1)
745 {
746 stop_sfx(itemsbuf[div_prot_item].usesound);
747 stop_sfx(itemsbuf[div_prot_item].usesound+1);
748 }
749
750 372 div_prot_item = -1;
751 372 hoverclk=jumping=0;
752 372 hoverflags = 0;
753 372 }
754 35854 damageovertimeclk = 0;
755 35854 newconveyorclk = 0;
756 35854 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
757
2/2
✓ Branch 0 taken 35854 times.
✓ Branch 1 taken 250978 times.
286832 for(auto q = 0; q < 7; ++q)
758 250978 hooked_undercombos[q] = -1;
759 35854 hopclk=0;
760 35854 hopdir=-1;
761 35854 attackclk=0;
762 35854 stomping=false;
763 35854 reset_swordcharge();
764 35854 diveclk=drownclk=drownCombo=0;
765 35854 action=none; FFCore.setHeroAction(none);
766 35854 conveyor_flags=0;
767 35854 magiccastclk=0;
768 35854 magicitem=-1;
769 35854 }
770
771 //Can use this for Hero->Stun. -Z
772 14692 void HeroClass::Freeze()
773 {
774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14692 times.
14692 if (action != inwind)
775 {
776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14692 times.
14692 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
777 14692 else {action=freeze; FFCore.setHeroAction(freeze);}
778 // also cancel Hero's attack
779 14692 attackclk = 0;
780 14692 }
781 14692 }
782 5897 void HeroClass::unfreeze()
783 {
784
4/4
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 4617 times.
✓ Branch 2 taken 1279 times.
✓ Branch 3 taken 1 times.
5897 if(action==freeze && fairyclk<1) { action=none; FFCore.setHeroAction(none); }
785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5897 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5897 if(action==sideswimfreeze && fairyclk<1) { action=sideswimming; FFCore.setHeroAction(sideswimming); }
786 5897 }
787
788 192 void HeroClass::Drown(int32_t state)
789 {
790 // Hero should never drown if the ladder is out
791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(ladderx+laddery)
792 return;
793
794 192 drop_liftwpn();
795
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 4 times.
192 switch(state)
796 {
797 case 1:
798 4 action=lavadrowning; FFCore.setHeroAction(lavadrowning);
799 4 attackclk=0;
800 4 attack=wNone;
801 4 attackid=-1;
802 4 reset_swordcharge();
803 4 drownclk=64;
804 4 z=fakez=fall=fakefall=0;
805 4 break;
806
807
808 default:
809 {
810
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 188 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
188 if (isSideViewHero() && get_qr(qr_SIDESWIM)){action=sidedrowning; FFCore.setHeroAction(sidedrowning);}
811 188 else {action=drowning; FFCore.setHeroAction(drowning);}
812 188 attackclk=0;
813 188 attack=wNone;
814 188 attackid=-1;
815 188 reset_swordcharge();
816 188 drownclk=64;
817 188 z=fakez=fall=fakefall=0;
818 188 break;
819 }
820 }
821
822 192 }
823
824 4619 void HeroClass::finishedmsg()
825 {
826 //these are to cancel out any keys that Hero may
827 //be pressing so he doesn't attack at the end of
828 //a message if he was scrolling through it quickly.
829 4619 rAbtn();
830 4619 rBbtn();
831 4619 unfreeze();
832
833
3/4
✓ Branch 0 taken 4525 times.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4494 times.
9113 if(action == landhold1 ||
834
2/2
✓ Branch 0 taken 4496 times.
✓ Branch 1 taken 29 times.
4525 action == landhold2 ||
835
2/2
✓ Branch 0 taken 4495 times.
✓ Branch 1 taken 1 times.
4496 action == waterhold1 ||
836
2/2
✓ Branch 0 taken 4494 times.
✓ Branch 1 taken 1 times.
4495 action == waterhold2 ||
837
1/2
✓ Branch 0 taken 4494 times.
✗ Branch 1 not taken.
4494 action == sidewaterhold1 ||
838 4494 action == sidewaterhold2)
839 {
840 125 holdclk = 1;
841 125 }
842 4619 }
843 78 void HeroClass::setEaten(int32_t i)
844 {
845 78 inlikelike=i;
846 78 }
847 70 int32_t HeroClass::getEaten()
848 {
849 70 return inlikelike;
850 }
851 60597890 zfix HeroClass::getX()
852 {
853 60597890 return x;
854 }
855 61022395 zfix HeroClass::getY()
856 {
857 61022395 return y;
858 }
859 89664915 zfix HeroClass::getZ()
860 {
861 89664915 return z;
862 }
863 55193562 zfix HeroClass::getFakeZ()
864 {
865 55193562 return fakez;
866 }
867 641401 zfix HeroClass::getFall()
868 {
869 641401 return fall;
870 }
871 zfix HeroClass::getFakeFall()
872 {
873 return fakefall;
874 }
875 zfix HeroClass::getXOfs()
876 {
877 return xofs;
878 }
879 1344 zfix HeroClass::getYOfs()
880 {
881 1344 return yofs;
882 }
883 void HeroClass::setXOfs(int32_t newxofs)
884 {
885 xofs=newxofs;
886 }
887 void HeroClass::setYOfs(int32_t newyofs)
888 {
889 yofs=newyofs;
890 }
891 int32_t HeroClass::getHXOfs()
892 {
893 return hxofs;
894 }
895 int32_t HeroClass::getHYOfs()
896 {
897 return hyofs;
898 }
899 int32_t HeroClass::getHXSz()
900 {
901 return hit_width;
902 }
903 int32_t HeroClass::getHYSz()
904 {
905 return hit_height;
906 }
907 88064 zfix HeroClass::getClimbCoverX()
908 {
909 88064 return climb_cover_x;
910 }
911 88064 zfix HeroClass::getClimbCoverY()
912 {
913 88064 return climb_cover_y;
914 }
915 int32_t HeroClass::getLadderX()
916 {
917 return ladderx;
918 }
919 int32_t HeroClass::getLadderY()
920 {
921 return laddery;
922 }
923
924 459866 void HeroClass::setX(int32_t new_x)
925 {
926 459866 zfix dx=new_x-x;
927 459866 justmoved = 2;
928
2/2
✓ Branch 0 taken 459845 times.
✓ Branch 1 taken 21 times.
459866 if(Lwpns.idFirst(wHookshot)>-1)
929 {
930 21 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
931 21 hs_startx+=(int32_t)dx;
932 21 }
933
934
2/2
✓ Branch 0 taken 459845 times.
✓ Branch 1 taken 21 times.
459866 if(Lwpns.idFirst(wHSHandle)>-1)
935 {
936 21 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
937 21 }
938
939
2/2
✓ Branch 0 taken 459857 times.
✓ Branch 1 taken 9 times.
459866 if(chainlinks.Count()>0)
940 {
941
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 9 times.
28 for(int32_t j=0; j<chainlinks.Count(); j++)
942 {
943 19 chainlinks.spr(j)->x+=dx;
944 19 }
945 9 }
946
947 459866 x=new_x;
948
949 // A kludge
950
4/4
✓ Branch 0 taken 3704 times.
✓ Branch 1 taken 456162 times.
✓ Branch 2 taken 2385 times.
✓ Branch 3 taken 1319 times.
459866 if(!diagonalMovement && dir<=down)
951 1319 is_on_conveyor=true;
952 459866 }
953
954 474142 void HeroClass::setY(int32_t new_y)
955 {
956 474142 zfix dy=new_y-y;
957 474142 justmoved = 2;
958
2/2
✓ Branch 0 taken 474133 times.
✓ Branch 1 taken 9 times.
474142 if(Lwpns.idFirst(wHookshot)>-1)
959 {
960 9 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
961 9 hs_starty+=(int32_t)dy;
962 9 }
963
964
2/2
✓ Branch 0 taken 474133 times.
✓ Branch 1 taken 9 times.
474142 if(Lwpns.idFirst(wHSHandle)>-1)
965 {
966 9 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
967 9 }
968
969
1/2
✓ Branch 0 taken 474142 times.
✗ Branch 1 not taken.
474142 if(chainlinks.Count()>0)
970 {
971 for(int32_t j=0; j<chainlinks.Count(); j++)
972 {
973 chainlinks.spr(j)->y+=dy;
974 }
975 }
976
977 474142 y=new_y;
978
979 // A kludge
980
4/4
✓ Branch 0 taken 3704 times.
✓ Branch 1 taken 470438 times.
✓ Branch 2 taken 1319 times.
✓ Branch 3 taken 2385 times.
474142 if(!diagonalMovement && dir>=left)
981 2385 is_on_conveyor=true;
982 474142 }
983
984 4 void HeroClass::setZ(int32_t new_z)
985 {
986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(isSideViewHero())
987 return;
988
989
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(z==0 && new_z > 0)
990 {
991
1/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 switch(action)
992 {
993 case swimming:
994 {
995 diveclk=0;
996 action=walking; FFCore.setHeroAction(walking);
997 break;
998 }
999
1000 case waterhold1:
1001 {
1002 action=landhold1; FFCore.setHeroAction(landhold1);
1003 break;
1004 }
1005
1006 case waterhold2:
1007 {
1008 action=landhold2; FFCore.setHeroAction(landhold2);
1009 break;
1010 }
1011
1012 default:
1013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(charging) //!DIMITODO: Let Hero jump while charging sword
1014 {
1015 reset_swordcharge();
1016 attackclk=0;
1017 }
1018
1019 4 break;
1020 }
1021 4 }
1022
1023
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 z=(new_z>0 ? new_z : 0);
1024 4 }
1025
1026 void HeroClass::setFakeZ(int32_t new_z)
1027 {
1028 if(isSideViewHero())
1029 return;
1030
1031 if(fakez==0 && new_z > 0)
1032 {
1033 switch(action)
1034 {
1035 case swimming:
1036 {
1037 diveclk=0;
1038 action=walking; FFCore.setHeroAction(walking);
1039 break;
1040 }
1041
1042 case waterhold1:
1043 {
1044 action=landhold1; FFCore.setHeroAction(landhold1);
1045 break;
1046 }
1047
1048 case waterhold2:
1049 {
1050 action=landhold2; FFCore.setHeroAction(landhold2);
1051 break;
1052 }
1053
1054 default:
1055 if(charging) //!DIMITODO: Let Hero jump while charging sword
1056 {
1057 reset_swordcharge();
1058 attackclk=0;
1059 }
1060
1061 break;
1062 }
1063 }
1064
1065 fakez=(new_z>0 ? new_z : 0);
1066 }
1067
1068 23601 void HeroClass::setXfix(zfix new_x)
1069 {
1070 //Z_scripterrlog("setxdbl: %f\n",new_x);
1071 23601 zfix dx=new_x-x;
1072 23601 justmoved = 2;
1073
2/2
✓ Branch 0 taken 23591 times.
✓ Branch 1 taken 10 times.
23601 if(Lwpns.idFirst(wHookshot)>-1)
1074 {
1075 10 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
1076 10 hs_startx+=(int32_t)dx;
1077 10 }
1078
1079
2/2
✓ Branch 0 taken 23591 times.
✓ Branch 1 taken 10 times.
23601 if(Lwpns.idFirst(wHSHandle)>-1)
1080 {
1081 10 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
1082 10 }
1083
1084
2/2
✓ Branch 0 taken 23594 times.
✓ Branch 1 taken 7 times.
23601 if(chainlinks.Count()>0)
1085 {
1086
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 7 times.
22 for(int32_t j=0; j<chainlinks.Count(); j++)
1087 {
1088 15 chainlinks.spr(j)->x+=dx;
1089 15 }
1090 7 }
1091
1092 23601 x=new_x;
1093
1094 // A kludge
1095
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23601 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23601 if(!diagonalMovement && dir<=down)
1096 is_on_conveyor=true;
1097 23601 }
1098
1099 22827 void HeroClass::setYfix(zfix new_y)
1100 {
1101 22827 zfix dy=new_y-y;
1102 22827 justmoved = 2;
1103
2/2
✓ Branch 0 taken 22787 times.
✓ Branch 1 taken 40 times.
22827 if(Lwpns.idFirst(wHookshot)>-1)
1104 {
1105 40 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
1106 40 hs_starty+=(int32_t)dy;
1107 40 }
1108
1109
2/2
✓ Branch 0 taken 22787 times.
✓ Branch 1 taken 40 times.
22827 if(Lwpns.idFirst(wHSHandle)>-1)
1110 {
1111 40 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
1112 40 }
1113
1114
2/2
✓ Branch 0 taken 22793 times.
✓ Branch 1 taken 34 times.
22827 if(chainlinks.Count()>0)
1115 {
1116
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 34 times.
213 for(int32_t j=0; j<chainlinks.Count(); j++)
1117 {
1118 179 chainlinks.spr(j)->y+=dy;
1119 179 }
1120 34 }
1121
1122 22827 y=new_y;
1123
1124 // A kludge
1125
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22827 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22827 if(!diagonalMovement && dir>=left)
1126 is_on_conveyor=true;
1127 22827 }
1128
1129 2775 void HeroClass::setZfix(zfix new_z)
1130 {
1131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2775 times.
2775 if(isSideViewHero())
1132 return;
1133
1134
4/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 2755 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 14 times.
2775 if(z==0 && new_z > 0)
1135 {
1136
1/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 switch(action)
1137 {
1138 case swimming:
1139 {
1140 diveclk=0;
1141 action=walking; FFCore.setHeroAction(walking);
1142 break;
1143 }
1144
1145 case waterhold1:
1146 {
1147 action=landhold1; FFCore.setHeroAction(landhold1);
1148 break;
1149 }
1150
1151 case waterhold2:
1152 {
1153 action=landhold2; FFCore.setHeroAction(landhold2);
1154 break;
1155 }
1156
1157 default:
1158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(charging) //!DIMITODO: Let Hero jump while charging sword
1159 {
1160 reset_swordcharge();
1161 attackclk=0;
1162 }
1163
1164 14 break;
1165 }
1166 14 }
1167
1168
2/2
✓ Branch 0 taken 2768 times.
✓ Branch 1 taken 7 times.
2775 z=(new_z>0 ? new_z : 0_zf);
1169 2775 }
1170
1171 void HeroClass::setFakeZfix(zfix new_z)
1172 {
1173 if(isSideViewHero())
1174 return;
1175
1176 if(fakez==0 && new_z > 0)
1177 {
1178 switch(action)
1179 {
1180 case swimming:
1181 {
1182 diveclk=0;
1183 action=walking; FFCore.setHeroAction(walking);
1184 break;
1185 }
1186
1187 case waterhold1:
1188 {
1189 action=landhold1; FFCore.setHeroAction(landhold1);
1190 break;
1191 }
1192
1193 case waterhold2:
1194 {
1195 action=landhold2; FFCore.setHeroAction(landhold2);
1196 break;
1197 }
1198
1199 default:
1200 if(charging) //!DIMITODO: Let Hero jump while charging sword
1201 {
1202 reset_swordcharge();
1203 attackclk=0;
1204 }
1205
1206 break;
1207 }
1208 }
1209
1210 fakez=(new_z>0 ? new_z : 0_zf);
1211 }
1212
1213 64852 void HeroClass::setFall(zfix new_fall)
1214 {
1215 64852 fall=new_fall;
1216 64852 justmoved = 2;
1217 64852 jumping=-1;
1218 64852 }
1219 void HeroClass::setFakeFall(zfix new_fall)
1220 {
1221 fakefall=new_fall;
1222 jumping=-1;
1223 }
1224 void HeroClass::setClimbCoverX(int32_t new_x)
1225 {
1226 climb_cover_x=new_x;
1227 }
1228 void HeroClass::setClimbCoverY(int32_t new_y)
1229 {
1230 climb_cover_y=new_y;
1231 }
1232 132628 int32_t HeroClass::getLStep()
1233 {
1234 132628 return lstep;
1235 }
1236 5756 int32_t HeroClass::getCharging()
1237 {
1238 5756 return charging;
1239 }
1240 127163 bool HeroClass::isCharged()
1241 {
1242 127163 return spins>0;
1243 }
1244 2 int32_t HeroClass::getAttackClk()
1245 {
1246 2 return attackclk;
1247 }
1248 2 void HeroClass::setAttackClk(int32_t new_clk)
1249 {
1250 2 attackclk=new_clk;
1251 2 }
1252 void HeroClass::setCharging(int32_t new_charging)
1253 {
1254 charging=new_charging;
1255 }
1256 2918138090 int32_t HeroClass::getSwordClk()
1257 {
1258 2918138090 return swordclk;
1259 }
1260 2851183785 int32_t HeroClass::getItemClk()
1261 {
1262 2851183785 return itemclk;
1263 }
1264 2850968627 int32_t HeroClass::getShieldClk()
1265 {
1266 2850968627 return shieldjinxclk;
1267 }
1268 716 void HeroClass::setSwordClk(int32_t newclk)
1269 {
1270 716 swordclk=newclk;
1271 716 verifyAWpn();
1272 716 }
1273 5873 void HeroClass::setItemClk(int32_t newclk)
1274 {
1275 5873 itemclk=newclk;
1276 5873 }
1277 2 void HeroClass::setShieldClk(int32_t newclk)
1278 {
1279 2 shieldjinxclk=newclk;
1280 2 }
1281 // TODO remove, no longer needed.
1282 1250668 zfix HeroClass::getModifiedX()
1283 {
1284 1250668 zfix tempx=x;
1285 1250668 return tempx;
1286 }
1287
1288 1250668 zfix HeroClass::getModifiedY()
1289 {
1290 1250668 zfix tempy=y;
1291 1250668 return tempy;
1292 }
1293
1294 64167 int32_t HeroClass::getDir()
1295 {
1296 64167 return dir;
1297 }
1298 93583 void HeroClass::setDir(int32_t newdir)
1299 {
1300 93583 dir=newdir;
1301 93583 reset_hookshot();
1302 93583 }
1303 441276 int32_t HeroClass::getHitDir()
1304 {
1305 441276 return hitdir;
1306 }
1307 2220 void HeroClass::setHitDir(int32_t newdir)
1308 {
1309 2220 hitdir = newdir;
1310 2220 }
1311 int32_t HeroClass::getClk()
1312 {
1313 return clk;
1314 }
1315 178963 int32_t HeroClass::getPushing()
1316 {
1317 178963 return pushing;
1318 }
1319 15582 void HeroClass::Catch()
1320 {
1321
5/6
✓ Branch 0 taken 15582 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12602 times.
✓ Branch 3 taken 2980 times.
✓ Branch 4 taken 6224 times.
✓ Branch 5 taken 6378 times.
15582 if(!inwallm && (action==none || action==walking))
1322 {
1323 9204 SetAttack();
1324 9204 attackclk=0;
1325 9204 attack=wCatching;
1326 9204 }
1327 15582 }
1328
1329 4372160 bool HeroClass::getClock()
1330 {
1331 4372160 return superman;
1332 }
1333 952 void HeroClass::setClock(bool state)
1334 {
1335 952 superman=state;
1336 952 }
1337 16550780 int32_t HeroClass::getFlashingCSet()
1338 {
1339 16550780 int32_t temp_cs = 6;
1340
2/2
✓ Branch 0 taken 16297892 times.
✓ Branch 1 taken 252888 times.
16550780 if (script_hero_cset > -1) temp_cs = script_hero_cset;
1341
2/2
✓ Branch 0 taken 2277803 times.
✓ Branch 1 taken 14272977 times.
16550780 if (!get_qr(qr_HEROFLICKER))
1342 {
1343
3/4
✓ Branch 0 taken 120557 times.
✓ Branch 1 taken 14152420 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120557 times.
14272977 if (superman && getCanFlicker())
1344 {
1345 120557 temp_cs += (((~frame) >> 1) & 3);
1346 120557 }
1347
4/6
✓ Branch 0 taken 629740 times.
✓ Branch 1 taken 13522680 times.
✓ Branch 2 taken 629740 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 629740 times.
14152420 else if (hclk && (DivineProtectionShieldClk <= 0) && getCanFlicker())
1348 {
1349 629740 temp_cs += ((hclk >> 1) & 3);
1350 629740 }
1351 14272977 }
1352 16550780 return temp_cs;
1353 }
1354 17469053 bool HeroClass::is_hitflickerframe()
1355 {
1356
6/6
✓ Branch 0 taken 2428528 times.
✓ Branch 1 taken 15040525 times.
✓ Branch 2 taken 2365727 times.
✓ Branch 3 taken 62801 times.
✓ Branch 4 taken 107237 times.
✓ Branch 5 taken 2258490 times.
17469053 if (!(get_qr(qr_HEROFLICKER) && (superman || hclk)))
1357 17299015 return false;
1358
1359 170038 int32_t fr = game->get_spriteflickerspeed();
1360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170038 times.
170038 if (fr == 0)
1361 return true;
1362 170038 return frame % (fr * 2) >= fr;
1363 17469053 }
1364 94362974 int32_t HeroClass::getAction() // Used by ZScript
1365 {
1366
2/2
✓ Branch 0 taken 31122 times.
✓ Branch 1 taken 94331852 times.
94362974 if(spins > 0)
1367 31122 return isspinning;
1368
2/2
✓ Branch 0 taken 369381 times.
✓ Branch 1 taken 93962471 times.
94331852 else if(charging > 0)
1369 369381 return ischarging;
1370
2/2
✓ Branch 0 taken 93855285 times.
✓ Branch 1 taken 107186 times.
93962471 else if(diveclk > 0)
1371 107186 return isdiving;
1372 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1373
1374 93855285 return action;
1375 94362974 }
1376
1377 90078691 int32_t HeroClass::getAction2() // Used by ZScript new FFCore.actions
1378 {
1379
2/2
✓ Branch 0 taken 25963 times.
✓ Branch 1 taken 90052728 times.
90078691 if(spins > 0)
1380 25963 return isspinning;
1381
2/2
✓ Branch 0 taken 333968 times.
✓ Branch 1 taken 89718760 times.
90052728 else if(charging > 0)
1382 333968 return ischarging;
1383
2/2
✓ Branch 0 taken 89519811 times.
✓ Branch 1 taken 198949 times.
89718760 else if(diveclk > 0)
1384 198949 return isdiving;
1385 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1386
1387 89519811 return -1;
1388 90078691 }
1389
1390 5057 void HeroClass::setAction(actiontype new_action) // Used by ZScript
1391 {
1392
4/8
✓ Branch 0 taken 5057 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5057 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5057 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5057 times.
10114 if(new_action==dying || new_action==won || new_action==scrolling ||
1393
3/6
✓ Branch 0 taken 5057 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5057 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5057 times.
✗ Branch 5 not taken.
5057 new_action==inwind || new_action==ischarging || new_action==sideswimischarging ||
1394 5057 new_action==hopping) //!DIMITODO: allow setting sideswimming stuff
1395 return; // Can't use these actions.
1396
1397
3/6
✓ Branch 0 taken 4858 times.
✓ Branch 1 taken 199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4858 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5057 if (!isSideViewHero() && (new_action>=sideswimming && new_action <= sideswimischarging))
1398 return;
1399
1400
1/2
✓ Branch 0 taken 5057 times.
✗ Branch 1 not taken.
5057 if(new_action==rafting)
1401 {
1402 if(get_qr(qr_DISALLOW_SETTING_RAFTING)) return;
1403 if(!(isRaftFlag(nextflag(x+8,y+8,dir,false))||isRaftFlag(nextflag(x+8,y+8,dir,true))))
1404 return;
1405 }
1406
1407
1408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5057 if(magicitem>-1 && itemsbuf[magicitem].family==itype_divineescape)
1409 {
1410 // Using Divine Escape
1411 if(magiccastclk<96)
1412 {
1413 // Not cast yet; cancel it
1414 magicitem=-1;
1415 magiccastclk=0;
1416 }
1417 else
1418 // Already activated; don't do anything
1419 return;
1420 }
1421
1422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5057 times.
5057 if(action==inwind) // Remove from whirlwind
1423 {
1424 xofs=0;
1425 whirlwind=0;
1426 lstep=0;
1427 if ( dontdraw < 2 ) { dontdraw=0; }
1428 }
1429
2/4
✓ Branch 0 taken 5057 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5057 times.
5057 else if(action==freeze||action==sideswimfreeze) // Might be in enemy wind
1430 {
1431 sprite* wind=0;
1432 bool foundWind=false;
1433 for(int32_t i=0; i<Ewpns.Count(); i++)
1434 {
1435 wind=Ewpns.spr(i);
1436 if(wind->id==ewWind && wind->misc==999)
1437 {
1438 foundWind=true;
1439 break;
1440 }
1441 }
1442
1443 if(foundWind)
1444 {
1445 xofs=0;
1446 if ( dontdraw < 2 ) { dontdraw=false; }
1447 wind->misc=-1;
1448 x=wind->x;
1449 y=wind->y;
1450 }
1451 }
1452
1453 //Unless compat rule is on, reset hopping clocks when writing action!
1454
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5057 if(action == hopping && !get_qr(qr_NO_OVERWRITING_HOPPING))
1455 {
1456 hopclk = 0;
1457 hopdir = -1;
1458 }
1459
1460
3/4
✓ Branch 0 taken 2679 times.
✓ Branch 1 taken 2378 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2679 times.
5057 if(new_action != attacking && new_action != sideswimattacking)
1461 {
1462 2679 attackclk=0;
1463
1464
1/2
✓ Branch 0 taken 2679 times.
✗ Branch 1 not taken.
2679 if(attack==wHookshot)
1465 reset_hookshot();
1466 2679 }
1467
2/4
✓ Branch 0 taken 5057 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5057 times.
5057 if(new_action != isspinning && new_action != sideswimisspinning)
1468 {
1469 5057 charging = 0;
1470 5057 spins = 0;
1471 5057 }
1472
1473
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5057 if(action == falling && new_action != falling)
1474 {
1475 fallclk = 0; //Stop falling;
1476 }
1477
1478
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5057 if (action == rafting && new_action != rafting)
1479 {
1480 raftwarpx = x;//If you wanted to make Link stop rafting on a dock combo, don't make the dock retrigger the raft.
1481 raftwarpy = y;
1482 }
1483
1484
4/9
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2378 times.
✓ Branch 5 taken 2661 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5057 switch(new_action)
1485 {
1486 case isspinning:
1487 case sideswimisspinning:
1488 if(attack==wSword)
1489 {
1490 attackclk = SWORDCHARGEFRAME+1;
1491 charging = 0;
1492
1493 if(spins==0)
1494 spins = 5;
1495 }
1496 return;
1497
1498 case isdiving:
1499 if(action==swimming && diveclk==0)
1500 {
1501 int32_t flippers_id = current_item_id(itype_flippers);
1502 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2)); // Who cares about qr_NODIVING? It's the questmaker's business.
1503 }
1504 return;
1505
1506 case drowning:
1507 case sidedrowning:
1508 clear_platform_ffc();
1509 if(!drownclk)
1510 Drown();
1511
1512 break;
1513
1514 case lavadrowning:
1515 //Lavadrowning is just drowning but with a different argument. Simplicity! -Dimi
1516 clear_platform_ffc();
1517 if(!drownclk)
1518 Drown(1);
1519
1520 break;
1521
1522 case falling:
1523 clear_platform_ffc();
1524 if(!fallclk)
1525 {
1526 //If there is a pit under Hero, use its combo.
1527 if(int32_t c = getpitfall(x+8,y+(bigHitbox?8:12))) fallCombo = c;
1528 else if(int32_t c = getpitfall(x,y+(bigHitbox?0:8))) fallCombo = c;
1529 else if(int32_t c = getpitfall(x+15,y+(bigHitbox?0:8))) fallCombo = c;
1530 else if(int32_t c = getpitfall(x,y+15)) fallCombo = c;
1531 else if(int32_t c = getpitfall(x+15,y+15)) fallCombo = c;
1532 //Else, use a null value; triggers default pit values
1533 else fallCombo = 0;
1534 fallclk = PITFALL_FALL_FRAMES;
1535 }
1536 break;
1537
1538 case gothit:
1539 case swimhit:
1540 case sideswimhit:
1541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!hclk)
1542 1 hclk=48;
1543
1544 1 break;
1545
1546 case landhold1:
1547 case landhold2:
1548 case waterhold1:
1549 case waterhold2:
1550 case sidewaterhold1:
1551 case sidewaterhold2:
1552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(!holdclk)
1553 17 holdclk=130;
1554
1555 17 attack=none;
1556 17 break;
1557
1558 case attacking:
1559 case sideswimattacking:
1560 2378 attack=none;
1561 2378 break;
1562
1563 default:
1564 2661 break;
1565 }
1566
1567 5057 action=new_action; FFCore.setHeroAction(new_action);
1568 5057 }
1569
1570 48 void HeroClass::setHeldItem(int32_t newitem)
1571 {
1572 48 holditem=newitem;
1573 48 }
1574 200 int32_t HeroClass::getHeldItem()
1575 {
1576 200 return holditem;
1577 }
1578 20361388 bool HeroClass::isDiving()
1579 {
1580 20361388 int32_t flippers_id = current_item_id(itype_flippers);
1581
2/2
✓ Branch 0 taken 15052984 times.
✓ Branch 1 taken 5308404 times.
20361388 return (diveclk > (flippers_id < 0 ? 30 : itemsbuf[flippers_id].misc2));
1582 }
1583 44784875 bool HeroClass::isSwimming()
1584 {
1585 44784875 bool include_swimhit = true;
1586
3/4
✓ Branch 0 taken 44784875 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8622238 times.
✓ Branch 3 taken 36162637 times.
44784875 if (replay_is_active() && replay_version_check(0, 31))
1587 {
1588
2/4
✓ Branch 0 taken 36162637 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 36162637 times.
36162637 std::string qst = replay_get_meta_str("qst");
1589 36162637 bool disable = false;
1590
1/2
✓ Branch 0 taken 36162637 times.
✗ Branch 1 not taken.
36162637 disable |= qst == "demons_inferno.qst";
1591
1/2
✓ Branch 0 taken 36162637 times.
✗ Branch 1 not taken.
36162637 disable |= qst == "demosp253.qst";
1592
1/2
✓ Branch 0 taken 36162637 times.
✗ Branch 1 not taken.
36162637 disable |= qst == "hell_awaits.qst";
1593
1/2
✓ Branch 0 taken 36162637 times.
✗ Branch 1 not taken.
36162637 disable |= qst == "lands_of_serenity.qst";
1594
1/2
✓ Branch 0 taken 36162637 times.
✗ Branch 1 not taken.
36162637 disable |= qst == "link_to_the_heavens.qst";
1595 // The others are just a gfx change, but this one actual breaks without this compat check.
1596
1/2
✓ Branch 0 taken 36162637 times.
✗ Branch 1 not taken.
36162637 disable |= qst == "link_to_the_zelda.qst";
1597 36162637 include_swimhit = !disable;
1598 36162637 }
1599
4/6
✓ Branch 0 taken 44333671 times.
✓ Branch 1 taken 451204 times.
✓ Branch 2 taken 44333671 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 44333671 times.
✗ Branch 5 not taken.
89118546 return ((action==swimming)||(action==sideswimming)||IsSideSwim()||
1600
8/8
✓ Branch 0 taken 44329658 times.
✓ Branch 1 taken 4013 times.
✓ Branch 2 taken 44326899 times.
✓ Branch 3 taken 2759 times.
✓ Branch 4 taken 27846928 times.
✓ Branch 5 taken 16479971 times.
✓ Branch 6 taken 1166 times.
✓ Branch 7 taken 27845762 times.
44333671 (action==waterhold1)||(action==waterhold2)||(include_swimhit && action==swimhit)||
1601 44325733 (hopclk==0xFF));
1602 }
1603
1604 3279 void HeroClass::setDontDraw(byte new_dontdraw)
1605 {
1606 3279 dontdraw=new_dontdraw;
1607 3279 }
1608
1609 1951836 byte HeroClass::getDontDraw()
1610 {
1611 1951836 return dontdraw;
1612 }
1613
1614 3 void HeroClass::setHClk(int32_t newhclk)
1615 {
1616 3 hclk=newhclk;
1617 3 }
1618
1619 56468 int32_t HeroClass::getHClk()
1620 {
1621 56468 return hclk;
1622 }
1623
1624 11242282 int32_t HeroClass::getSpecialCave()
1625 {
1626 11242282 return specialcave; // used only by maps.cpp
1627 }
1628
1629 1440 void HeroClass::init()
1630 {
1631 1440 cache_tile_mod_clear();
1632 1440 usecounts.clear();
1633 1440 scale = 0;
1634 1440 rotation = 0;
1635 1440 do_animation = true;
1636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1440 times.
1440 if(lift_wpn)
1637 {
1638 delete lift_wpn;
1639 lift_wpn = nullptr;
1640 }
1641 1440 clear_platform_ffc();
1642 1440 liftclk = 0;
1643 1440 tliftclk = 0;
1644 1440 liftheight = 0;
1645 1440 liftflags = 0;
1646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1440 times.
1440 if ( dontdraw != 2 ) { dontdraw = 0; } //scripted dontdraw == 2, normal == 1, draw hero == 0
1647 1440 hookshot_used=false;
1648 1440 justmoved = 0;
1649 1440 hookshot_frozen=false;
1650 1440 onpassivedmg=false;
1651 1440 dir = up;
1652 1440 damageovertimeclk = 0;
1653 1440 newconveyorclk = 0;
1654 1440 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
1655
2/2
✓ Branch 0 taken 10080 times.
✓ Branch 1 taken 1440 times.
11520 for(auto q = 0; q < 7; ++q)
1656 10080 hooked_undercombos[q] = -1;
1657 1440 shiftdir = -1;
1658 1440 sideswimdir = right;
1659 1440 holddir = -1;
1660 1440 landswim = 0;
1661 1440 sdir = up;
1662 1440 ilswim=true;
1663 1440 walkable=false;
1664 1440 moveflags = move_obeys_grav | move_can_pitfall | move_can_waterdrown;
1665 1440 warp_sound = 0;
1666 1440 subscr_speed = zinit.subscrSpeed;
1667 1440 steprate = zinit.heroStep;
1668 1440 shove_offset = zinit.shove_offset;
1669 1440 is_warping = false;
1670 1440 coyotetime = 0;
1671
1672 1440 hammer_swim_up_offset = hammeroffsets[0];
1673 1440 hammer_swim_down_offset = hammeroffsets[1];
1674 1440 hammer_swim_left_offset = hammeroffsets[2];
1675 1440 hammer_swim_right_offset = hammeroffsets[3];
1676
1677 1440 prompt_combo = prompt_x = prompt_y = prompt_cset = 0;
1678
1679
2/2
✓ Branch 0 taken 544 times.
✓ Branch 1 taken 896 times.
1440 if(get_qr(qr_NOARRIVALPOINT))
1680 {
1681 544 x=tmpscr->warpreturnx[0];
1682 544 y=tmpscr->warpreturny[0];
1683 544 }
1684 else
1685 {
1686 896 x=tmpscr->warparrivalx;
1687 896 y=tmpscr->warparrivaly;
1688 }
1689
1690 1440 z=fakez=fall=fakefall=0;
1691 1440 hzsz = 12; // So that flying peahats can still hit him.
1692
1693
2/2
✓ Branch 0 taken 453 times.
✓ Branch 1 taken 987 times.
1440 if(x==0) dir=right;
1694
1695
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1422 times.
1440 if(x==240) dir=left;
1696
1697
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 986 times.
1440 if(y==0) dir=down;
1698
1699
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 1139 times.
1440 if(y==160) dir=up;
1700
1701 1440 lstep=0;
1702 1440 skipstep=0;
1703 1440 autostep=false;
1704 1440 attackclk=holdclk=hoverclk=jumping=raftclk=0;
1705 1440 attack=wNone;
1706 1440 attackid=-1;
1707 1440 action=none; FFCore.setHeroAction(none); tempaction=none;
1708 1440 xofs=0;
1709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1440 times.
1440 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
1710 1440 cs=6;
1711 1440 flickercolor=-1;
1712 1440 flickertransp=-1;
1713 1440 pushing=fairyclk=0;
1714 1440 id=0;
1715 1440 inlikelike=0;
1716 1440 superman=inwallm=false;
1717 1440 scriptcoldet=true;
1718 1440 blowcnt=whirlwind=specialcave=0;
1719 1440 hopclk=diveclk=fallclk=0;
1720 1440 fallCombo = 0;
1721 1440 pit_pulldir = -1;
1722 1440 hopdir=-1;
1723 1440 conveyor_flags=0;
1724 1440 drunkclk=0;
1725 1440 lstunclock = 0;
1726 1440 is_conveyor_stunned=0;
1727 1440 convey_forcex=convey_forcey=0;
1728 1440 drawstyle=3;
1729 1440 ffwarp = false;
1730 1440 stepoutindex=stepoutwr=stepoutdmap=stepoutscr=0;
1731 1440 stepnext=stepsecret=-1;
1732 1440 ffpit = false;
1733 1440 respawn_x=x;
1734 1440 respawn_y=y;
1735 1440 respawn_dmap=currdmap;
1736 1440 respawn_scr=currscr;
1737 1440 falling_oldy = y;
1738 1440 magiccastclk=0;
1739 1440 magicitem = div_prot_item = -1;
1740 1440 last_lens_id = 0; //Should be -1 (-Z)
1741 1440 last_lift_id.reset();
1742 1440 last_savepoint_id = 0;
1743 1440 misc_internal_hero_flags = 0;
1744 1440 last_cane_of_byrna_item_id = -1;
1745 1440 on_sideview_ladder = false;
1746 1440 switchblock_z = 0;
1747 1440 switchblock_offset = false;
1748 1440 extra_jump_count = 0;
1749 1440 hoverflags = 0;
1750 1440 lbunnyclock = 0;
1751 1440 lamp_paid = false;
1752
1753
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 1440 times.
47520 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
1754
1755 1440 setBigHitbox(get_qr(qr_LTTPCOLLISION));
1756 1440 diagonalMovement=(get_qr(qr_LTTPWALK));
1757
1758 1440 shield_active = false;
1759 1440 shield_forcedir = -1;
1760 1440 active_shield_id = -1;
1761 1440 conv_forcedir = -1;
1762
1763 1440 preventsubscreenfalling = false; //-Z
1764 1440 walkspeed = 0; //not used, yet. -Z
1765
2/2
✓ Branch 0 taken 24480 times.
✓ Branch 1 taken 1440 times.
25920 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][0] = 0;
1766
2/2
✓ Branch 0 taken 24480 times.
✓ Branch 1 taken 1440 times.
25920 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][1] = 0;
1767
2/2
✓ Branch 0 taken 210240 times.
✓ Branch 1 taken 1440 times.
211680 for ( int32_t q = 0; q < wMax; q++ )
1768 {
1769 210240 defence[q] = hero_defence[q]; //we will need to have a Hero section in the quest load/save code! -Z Added 3/26/21 - Jman
1770 210240 }
1771
1772 1440 clear_ice();
1773 1440 script_ice_combo = 0;
1774 //Run script!
1775
4/4
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 1244 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 106 times.
1440 if (( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ) && (game->get_hasplayed()) ) //if (!hasplayed) runs in game_loop()
1776 {
1777 90 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_INIT);
1778 90 FFCore.deallocateAllScriptOwned(ScriptType::Player, SCRIPT_PLAYER_INIT);
1779 90 FFCore.initZScriptHeroScripts(); //Clear the stack and the refinfo data to be ready for Hero's active script.
1780 90 set_respawn_point(); //screen entry at spawn; //This should be after the init script, so that Hero->X and Hero->Y set by the script
1781 //are properly set by the engine.
1782 90 }
1783 1440 FFCore.nostepforward = 0;
1784
1785
2/2
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 1124 times.
1440 if (replay_version_check(12))
1786 1124 z3step = 2;
1787 1440 }
1788
1789 16573690 void HeroClass::draw_under(BITMAP* dest)
1790 {
1791 16573690 int32_t c_raft=current_item_id(itype_raft);
1792 16573690 int32_t c_ladder=current_item_id(itype_ladder);
1793
1794
3/4
✓ Branch 0 taken 144426 times.
✓ Branch 1 taken 16429264 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 144426 times.
16573690 if(action==rafting && c_raft >-1)
1795 {
1796
4/4
✓ Branch 0 taken 106833 times.
✓ Branch 1 taken 37593 times.
✓ Branch 2 taken 82762 times.
✓ Branch 3 taken 61664 times.
144426 if(((dir==left) || (dir==right)) && (get_qr(qr_RLFIX)))
1797 {
1798 123328 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1799 61664 itemsbuf[c_raft].csets&15, rotate_value((itemsbuf[c_raft].misc_flags>>2)&3)^3);
1800 61664 }
1801 else
1802 {
1803 165524 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1804 82762 itemsbuf[c_raft].csets&15, (itemsbuf[c_raft].misc_flags>>2)&3);
1805 }
1806 144426 }
1807
1808
3/4
✓ Branch 0 taken 142297 times.
✓ Branch 1 taken 16431393 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 142297 times.
16573690 if(ladderx+laddery && c_ladder >-1)
1809 {
1810
4/4
✓ Branch 0 taken 67726 times.
✓ Branch 1 taken 74571 times.
✓ Branch 2 taken 44376 times.
✓ Branch 3 taken 23350 times.
142297 if((ladderdir>=left) && (get_qr(qr_RLFIX)))
1811 {
1812 88752 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1813 44376 itemsbuf[c_ladder].csets&15, rotate_value((itemsbuf[iRaft].misc_flags>>2)&3)^3);
1814 44376 }
1815 else
1816 {
1817 195842 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1818 97921 itemsbuf[c_ladder].csets&15, (itemsbuf[c_ladder].misc_flags>>2)&3);
1819 }
1820 142297 }
1821 16573690 }
1822
1823 18783 void HeroClass::drawshadow(BITMAP* dest, bool translucent)
1824 {
1825 18783 int32_t tempy=yofs;
1826 18783 yofs+=8;
1827 18783 shadowtile = wpnsbuf[spr_shadow].tile;
1828 18783 sprite::drawshadow(dest,translucent);
1829 18783 yofs=tempy;
1830 18783 }
1831
1832 // The Stone of Agony reacts to these flags.
1833 483872 bool HeroClass::agonyflag(int32_t flag)
1834 {
1835
2/2
✓ Branch 0 taken 483840 times.
✓ Branch 1 taken 32 times.
483872 switch(flag)
1836 {
1837 case mfWHISTLE:
1838 case mfANYFIRE:
1839 case mfARROW:
1840 case mfBOMB:
1841 case mfSBOMB:
1842 case mfBRANG:
1843 case mfMBRANG:
1844 case mfFBRANG:
1845 case mfSARROW:
1846 case mfGARROW:
1847 case mfSTRONGFIRE:
1848 case mfMAGICFIRE:
1849 case mfDIVINEFIRE:
1850 case mfWANDMAGIC:
1851 case mfREFMAGIC:
1852 case mfREFFIREBALL:
1853 case mfSWORD:
1854 case mfWSWORD:
1855 case mfMSWORD:
1856 case mfXSWORD:
1857 case mfSWORDBEAM:
1858 case mfWSWORDBEAM:
1859 case mfMSWORDBEAM:
1860 case mfXSWORDBEAM:
1861 case mfHOOKSHOT:
1862 case mfWAND:
1863 case mfHAMMER:
1864 case mfSTRIKE:
1865 32 return true;
1866 }
1867
1868 483840 return false;
1869 483872 }
1870
1871
1872 // Find the attack power of the current melee weapon.
1873 // The Whimsical Ring is applied on a target-by-target basis.
1874 1104017 int32_t HeroClass::weaponattackpower(int32_t itid)
1875 {
1876
1/2
✓ Branch 0 taken 1104017 times.
✗ Branch 1 not taken.
1104017 if(itid < 0)
1877 {
1878 itid = current_item_id(attack==wCByrna ? itype_cbyrna
1879 : attack==wWand ? itype_wand
1880 : attack==wHammer ? itype_hammer
1881 : itype_sword);
1882 }
1883
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1103997 times.
1104017 int32_t power = attack==wCByrna ? itemsbuf[itid].misc4 : itemsbuf[itid].power;
1884
1885 // Multiply it by the power of the spin attack/quake hammer, if applicable.
1886
2/2
✓ Branch 0 taken 2189 times.
✓ Branch 1 taken 1101828 times.
1104017 if(spins > 0)
1887 {
1888 2189 int scr = currentscroll;
1889
1/2
✓ Branch 0 taken 2189 times.
✗ Branch 1 not taken.
2189 if(scr < 0)
1890 {
1891 scr = current_item_id(attack==wHammer ? (spins>1?itype_quakescroll2:itype_quakescroll)
1892 : (spins>5 || current_item_id(itype_spinscroll) < 0)
1893 ? itype_spinscroll2 : itype_spinscroll);
1894 }
1895 2189 power *= itemsbuf[scr].power;
1896 2189 }
1897 1101828 else currentscroll = -1;
1898 1104017 return power;
1899 }
1900
1901 #define NET_CLK_TOTAL 24
1902 #define NET_DIR_INC (NET_CLK_TOTAL/3)
1903 // Must only be called once per frame!
1904 138 void HeroClass::positionNet(weapon *w, int32_t itemid)
1905 {
1906 138 itemid = vbound(itemid, 0, MAXITEMS-1);
1907 138 int32_t t = w->o_tile,
1908 138 wx = 1, wy = 1;
1909
1910 //Invert positioning clock if right-handed animation
1911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 int32_t clock = (itemsbuf[itemid].flags&item_flag2 ? (NET_CLK_TOTAL-1)-attackclk : attackclk);
1912
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
138 if(clock >= NET_CLK_TOTAL)
1913 w->dead = 0;
1914 138 int32_t tiledir = dir;
1915
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 69 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 38 times.
138 switch(dir)
1916 {
1917 case up:
1918 {
1919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(clock < NET_DIR_INC) tiledir = l_up;
1920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 else if(clock >= NET_DIR_INC*2) tiledir = r_up;
1921 8 break;
1922 }
1923 case down:
1924 {
1925
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 48 times.
69 if(clock < NET_DIR_INC) tiledir = r_down;
1926
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
48 else if(clock >= NET_DIR_INC*2) tiledir = l_down;
1927 69 break;
1928 }
1929 case left:
1930 {
1931
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(clock < NET_DIR_INC) tiledir = l_down;
1932
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 else if(clock >= NET_DIR_INC*2) tiledir = l_up;
1933 23 break;
1934 }
1935 case right:
1936 {
1937
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 24 times.
38 if(clock < NET_DIR_INC) tiledir = r_up;
1938
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
24 else if(clock >= NET_DIR_INC*2) tiledir = r_down;
1939 38 break;
1940 }
1941 }
1942 138 int32_t offs = 0;
1943
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 48 times.
138 if(tiledir > right)
1944 90 offs = ((clock%NET_DIR_INC)<NET_DIR_INC/2) ? 1 : 0;
1945 48 else offs = vbound(((clock%NET_DIR_INC)/(NET_DIR_INC/3))-1,-1,1);
1946 //One of 8 positions
1947
7/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 29 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 31 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 8 times.
138 switch(tiledir)
1948 {
1949 case up:
1950 {
1951 wx = 6*offs;
1952 wy = -14;
1953 break;
1954 }
1955 case r_up:
1956 {
1957 22 wx = (offs ? 10 : 14);
1958 22 wy = (offs ? -12 : -10);
1959 22 break;
1960 }
1961 case right:
1962 {
1963 16 wx = 14;
1964 16 wy = 6*offs;
1965 16 break;
1966 }
1967 case r_down:
1968 {
1969 29 wx = (offs ? 14 : 10);
1970 29 wy = (offs ? 10 : 12);
1971 29 break;
1972 }
1973 case down:
1974 {
1975 24 wx = -6*offs;
1976 24 wy = 14;
1977 24 break;
1978 }
1979 case l_down:
1980 {
1981 31 wx = (offs ? -10 : -14);
1982 31 wy = (offs ? 12 : 10);
1983 31 break;
1984 }
1985 case left:
1986 {
1987 8 wx = -14;
1988 8 wy = -6*offs;
1989 8 break;
1990 }
1991 case l_up:
1992 {
1993 8 wx = (offs ? -14 : -10);
1994 8 wy = (offs ? -10 : -12);
1995 8 break;
1996 }
1997 }
1998
1999 138 w->x = x+wx;
2000 138 w->y = y+wy-(54-(yofs))-fakez;
2001 138 w->z = (z+zofs);
2002 138 w->fakez = fakez;
2003 138 w->tile = t+tiledir;
2004 138 w->power = 0;
2005 138 w->dir = dir;
2006 138 w->doAutoRotate(true);
2007 138 }
2008 965079 void HeroClass::positionSword(weapon *w, int32_t itemid)
2009 {
2010 //if ( w->ScriptGenerated ) return; //t/b/a for script-generated swords.
2011 //if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2012 965079 itemid=vbound(itemid, 0, MAXITEMS-1);
2013 // Place a sword weapon at the right spot.
2014 965079 int32_t wy=1;
2015 965079 int32_t wx=1;
2016 965079 int32_t f=0,t,cs2;
2017
2018 965079 t = w->o_tile;
2019 965079 cs2 = w->o_cset;
2020 965079 slashxofs=0;
2021 965079 slashyofs=0;
2022
2023
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 197442 times.
✓ Branch 2 taken 208289 times.
✓ Branch 3 taken 278982 times.
✓ Branch 4 taken 280366 times.
965079 switch(dir)
2024 {
2025 case up:
2026 197442 wx=-1;
2027 197442 wy=-12;
2028
2029
8/8
✓ Branch 0 taken 88286 times.
✓ Branch 1 taken 109156 times.
✓ Branch 2 taken 86709 times.
✓ Branch 3 taken 1577 times.
✓ Branch 4 taken 86299 times.
✓ Branch 5 taken 410 times.
✓ Branch 6 taken 8142 times.
✓ Branch 7 taken 78157 times.
197442 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & item_flag4 && charging==0)
2030 {
2031
2/2
✓ Branch 0 taken 50096 times.
✓ Branch 1 taken 28061 times.
78157 if(attackclk>10) //extended stab
2032 {
2033 28061 slashyofs-=3;
2034 28061 wy-=2;
2035 28061 }
2036
2037
2/2
✓ Branch 0 taken 69755 times.
✓ Branch 1 taken 8402 times.
78157 if(attackclk>=14) //retracting stab
2038 {
2039 8402 slashyofs+=3;
2040 8402 wy+=2;
2041 8402 }
2042 78157 }
2043 else
2044 {
2045
2/2
✓ Branch 0 taken 6746 times.
✓ Branch 1 taken 112539 times.
119285 if(attackclk==SWORDCHARGEFRAME)
2046 {
2047 6746 wy+=4;
2048 6746 }
2049
2/2
✓ Branch 0 taken 10909 times.
✓ Branch 1 taken 101630 times.
112539 else if(attackclk==13)
2050 {
2051 10909 wy+=4;
2052 10909 }
2053
2/2
✓ Branch 0 taken 90829 times.
✓ Branch 1 taken 10801 times.
101630 else if(attackclk==14)
2054 {
2055 10801 wy+=8;
2056 10801 }
2057 }
2058
2059 197442 break;
2060
2061 case down:
2062 208289 f=get_qr(qr_SWORDWANDFLIPFIX)?3:2;
2063 208289 wy=11;
2064
2065
8/8
✓ Branch 0 taken 111445 times.
✓ Branch 1 taken 96844 times.
✓ Branch 2 taken 110042 times.
✓ Branch 3 taken 1403 times.
✓ Branch 4 taken 109682 times.
✓ Branch 5 taken 360 times.
✓ Branch 6 taken 6988 times.
✓ Branch 7 taken 102694 times.
208289 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & item_flag4 && charging==0)
2066 {
2067
2/2
✓ Branch 0 taken 64615 times.
✓ Branch 1 taken 38079 times.
102694 if(attackclk>10) //extended stab
2068 {
2069 38079 slashyofs+=3;
2070 38079 wy+=2;
2071 38079 }
2072
2073
2/2
✓ Branch 0 taken 91151 times.
✓ Branch 1 taken 11543 times.
102694 if(attackclk>=14) //retracting stab
2074 {
2075 11543 slashyofs-=3;
2076 11543 wy-=2;
2077 11543 }
2078 102694 }
2079 else
2080 {
2081
2/2
✓ Branch 0 taken 6473 times.
✓ Branch 1 taken 99122 times.
105595 if(attackclk==SWORDCHARGEFRAME)
2082 {
2083 6473 wy-=2;
2084 6473 }
2085
2/2
✓ Branch 0 taken 9870 times.
✓ Branch 1 taken 89252 times.
99122 else if(attackclk==13)
2086 {
2087 9870 wy-=4;
2088 9870 }
2089
2/2
✓ Branch 0 taken 79417 times.
✓ Branch 1 taken 9835 times.
89252 else if(attackclk==14)
2090 {
2091 9835 wy-=8;
2092 9835 }
2093 }
2094
2095 208289 break;
2096
2097 case left:
2098 278982 f=1;
2099 278982 wx=-11;
2100 278982 ++t;
2101
2102
8/8
✓ Branch 0 taken 157598 times.
✓ Branch 1 taken 121384 times.
✓ Branch 2 taken 153899 times.
✓ Branch 3 taken 3699 times.
✓ Branch 4 taken 153047 times.
✓ Branch 5 taken 852 times.
✓ Branch 6 taken 10065 times.
✓ Branch 7 taken 142982 times.
278982 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & item_flag4 && charging==0)
2103 {
2104
2/2
✓ Branch 0 taken 88998 times.
✓ Branch 1 taken 53984 times.
142982 if(attackclk>10) //extended stab
2105 {
2106 53984 slashxofs-=4;
2107 53984 wx-=7;
2108 53984 }
2109
2110
2/2
✓ Branch 0 taken 127112 times.
✓ Branch 1 taken 15870 times.
142982 if(attackclk>=14) //retracting stab
2111 {
2112 15870 slashxofs+=3;
2113 15870 wx+=7;
2114 15870 }
2115 142982 }
2116 else
2117 {
2118
2/2
✓ Branch 0 taken 8752 times.
✓ Branch 1 taken 127248 times.
136000 if(attackclk==SWORDCHARGEFRAME)
2119 {
2120 8752 wx+=2;
2121 8752 }
2122
2/2
✓ Branch 0 taken 12652 times.
✓ Branch 1 taken 114596 times.
127248 else if(attackclk==13)
2123 {
2124 12652 wx+=4;
2125 12652 }
2126
2/2
✓ Branch 0 taken 101987 times.
✓ Branch 1 taken 12609 times.
114596 else if(attackclk==14)
2127 {
2128 12609 wx+=8;
2129 12609 }
2130 }
2131
2132 278982 break;
2133
2134 case right:
2135 280366 wx=11;
2136 280366 ++t;
2137
2138
8/8
✓ Branch 0 taken 152723 times.
✓ Branch 1 taken 127643 times.
✓ Branch 2 taken 149921 times.
✓ Branch 3 taken 2802 times.
✓ Branch 4 taken 148087 times.
✓ Branch 5 taken 1834 times.
✓ Branch 6 taken 13666 times.
✓ Branch 7 taken 134421 times.
280366 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & item_flag4 && charging==0)
2139 {
2140
2/2
✓ Branch 0 taken 83298 times.
✓ Branch 1 taken 51123 times.
134421 if(attackclk>10) //extended stab
2141 {
2142 51123 slashxofs+=4;
2143 51123 wx+=7;
2144 51123 }
2145
2146
2/2
✓ Branch 0 taken 118829 times.
✓ Branch 1 taken 15592 times.
134421 if(attackclk>=14) //retracting stab
2147 {
2148 15592 slashxofs-=3;
2149 15592 wx-=7;
2150 15592 }
2151 134421 }
2152 else
2153 {
2154
2/2
✓ Branch 0 taken 12322 times.
✓ Branch 1 taken 133623 times.
145945 if(attackclk==SWORDCHARGEFRAME)
2155 {
2156 12322 wx-=2;
2157 12322 }
2158
2/2
✓ Branch 0 taken 13265 times.
✓ Branch 1 taken 120358 times.
133623 else if(attackclk==13)
2159 {
2160 13265 wx-=4;
2161 13265 }
2162
2/2
✓ Branch 0 taken 107131 times.
✓ Branch 1 taken 13227 times.
120358 else if(attackclk==14)
2163 {
2164 13227 wx-=8;
2165 13227 }
2166 }
2167
2168 280366 break;
2169 }
2170
2171
6/6
✓ Branch 0 taken 510052 times.
✓ Branch 1 taken 455027 times.
✓ Branch 2 taken 499901 times.
✓ Branch 3 taken 10151 times.
✓ Branch 4 taken 211097 times.
✓ Branch 5 taken 288804 times.
965079 if(game->get_canslash() && itemsbuf[itemid].flags & item_flag4 && attackclk<11)
2172 {
2173 288804 int32_t wpn2=itemsbuf[itemid].wpn2;
2174 288804 wpn2=vbound(wpn2, 0, MAXWPNS);
2175
2176 //slashing tiles
2177
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 50381 times.
✓ Branch 2 taken 65009 times.
✓ Branch 3 taken 89631 times.
✓ Branch 4 taken 83783 times.
288804 switch(dir)
2178 {
2179 case up:
2180 50381 wx=15;
2181 50381 wy=-3;
2182 50381 ++t;
2183 50381 f=0; //starts pointing right
2184
2185
2/2
✓ Branch 0 taken 22471 times.
✓ Branch 1 taken 27910 times.
50381 if(attackclk>=7)
2186 {
2187 27910 wy-=9;
2188 27910 wx-=3;
2189 27910 t = wpnsbuf[wpn2].tile;
2190 27910 cs2 = wpnsbuf[wpn2].csets&15;
2191 27910 f=0;
2192 27910 }
2193
2194 50381 break;
2195
2196 case down:
2197 65009 wx=-13;
2198 65009 wy=-1;
2199 65009 ++t;
2200 65009 f=1; //starts pointing left
2201
2202
2/2
✓ Branch 0 taken 28379 times.
✓ Branch 1 taken 36630 times.
65009 if(attackclk>=7)
2203 {
2204 36630 wy+=15;
2205 36630 wx+=2;
2206 36630 t = wpnsbuf[wpn2].tile;
2207 36630 cs2 = wpnsbuf[wpn2].csets&15;
2208 36630 ++t;
2209 36630 f=0;
2210 36630 }
2211
2212 65009 break;
2213
2214 case left:
2215 89631 wx=3;
2216 89631 wy=-15;
2217 89631 --t;
2218 89631 f=0; //starts pointing up
2219
2220
2/2
✓ Branch 0 taken 38219 times.
✓ Branch 1 taken 51412 times.
89631 if(attackclk>=7)
2221 {
2222 51412 wx-=15;
2223 51412 wy+=3;
2224 51412 slashxofs-=1;
2225 51412 t = wpnsbuf[wpn2].tile;
2226 51412 cs2 = wpnsbuf[wpn2].csets&15;
2227 51412 t+=2;
2228 51412 f=0;
2229 51412 }
2230
2231 89631 break;
2232
2233 case right:
2234 83783 --t;
2235
2236
3/4
✓ Branch 0 taken 83370 times.
✓ Branch 1 taken 413 times.
✓ Branch 2 taken 83370 times.
✗ Branch 3 not taken.
83783 if(spins>0 || (itemsbuf[itemid].flags & item_flag8))
2237 {
2238 413 wx=1;
2239 413 wy=13;
2240 413 f=2;
2241 413 }
2242 else
2243 {
2244 83370 wx=3;
2245 83370 wy=-15;
2246 83370 f=0;
2247 }
2248
2249
2/2
✓ Branch 0 taken 35765 times.
✓ Branch 1 taken 48018 times.
83783 if(attackclk>=7)
2250 {
2251 48018 wx+=15;
2252 48018 slashxofs+=1;
2253 48018 t = wpnsbuf[wpn2].tile;
2254 48018 cs2 = wpnsbuf[wpn2].csets&15;
2255
2256
3/4
✓ Branch 0 taken 47743 times.
✓ Branch 1 taken 275 times.
✓ Branch 2 taken 47743 times.
✗ Branch 3 not taken.
48018 if(spins>0 || (itemsbuf[itemid].flags & item_flag8))
2257 {
2258 275 wx-=1;
2259 275 wy-=2;
2260 275 }
2261 else
2262 {
2263 47743 t+=3;
2264 47743 f=0;
2265 47743 wy+=3;
2266 }
2267 48018 }
2268
2269 83783 break;
2270 }
2271 288804 }
2272
2273 965079 int32_t itemid2 = current_item_id(itype_chargering);
2274
2275
4/4
✓ Branch 0 taken 27595 times.
✓ Branch 1 taken 937484 times.
✓ Branch 2 taken 951958 times.
✓ Branch 3 taken 13121 times.
965079 if(charging>(itemid2>=0 ? itemsbuf[itemid2].misc1 : 64))
2276 {
2277
2/2
✓ Branch 0 taken 12589 times.
✓ Branch 1 taken 532 times.
13121 cs2=(BSZ ? (frame&3)+6 : ((frame>>2)&1)+7);
2278 13121 }
2279
2280 /*if(BSZ || ((isdungeon() && currscr<128) && !get_qr(qr_HERODUNGEONPOSFIX)))
2281 {
2282 wy+=2;
2283 }*/
2284 965079 w->x = x+wx;
2285 965079 w->y = y+wy-(54-(yofs+slashyofs))-fakez;
2286 965079 w->z = (z+zofs);
2287 965079 w->tile = t;
2288 965079 w->flip = f;
2289 965079 w->power = weaponattackpower(itemid);
2290 965079 w->dir = dir;
2291 965079 w->doAutoRotate(true);
2292 965079 }
2293
2294 int HeroClass::getHammerState() const
2295 {
2296 if(attack == wHammer)
2297 {
2298 if(attackclk >= 15)
2299 return 3;
2300 if(attackclk >= 13)
2301 return 2;
2302 return 1;
2303 }
2304 return 0;
2305 }
2306 1094131 weapon* find_first_wtype(int wtype)
2307 {
2308
2/2
✓ Branch 0 taken 1177762 times.
✓ Branch 1 taken 88793 times.
1266555 for(int32_t i=0; i<Lwpns.Count(); i++)
2309 {
2310 1177762 weapon* w = (weapon*)Lwpns.spr(i);
2311
2312
2/2
✓ Branch 0 taken 1005338 times.
✓ Branch 1 taken 172424 times.
1177762 if(w->id == wtype)
2313 1005338 return w;
2314 172424 }
2315 88793 return nullptr;
2316 1094131 }
2317 16701861 void HeroClass::draw(BITMAP* dest)
2318 {
2319 /*{
2320 char buf[36];
2321 //sprintf(buf,"%d %d %d %d %d %d %d",dir, action, attack, attackclk, charging, spins, tapping);
2322 textout_shadowed_ex(framebuf,font, buf, 2,72,WHITE,BLACK,-1);
2323 }*/
2324 16701861 int32_t oxofs = xofs, oyofs = yofs;
2325 16701861 bool shieldModify = false;
2326
2/2
✓ Branch 0 taken 93446 times.
✓ Branch 1 taken 16608415 times.
16701861 bool invisible=(dontdraw>0) || (tmpscr->flags3&fINVISHERO);
2327
2328 {
2329
2/2
✓ Branch 0 taken 16535 times.
✓ Branch 1 taken 16685326 times.
16701861 if(action==dying)
2330 {
2331
2/2
✓ Branch 0 taken 12522 times.
✓ Branch 1 taken 4013 times.
16535 if(!invisible)
2332 {
2333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4013 times.
4013 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2334 4013 sprite::draw(dest);
2335 4013 }
2336 16535 goto herodraw_end;
2337 }
2338
2339 16685326 bool useltm=(get_qr(qr_EXPANDEDLTM) != 0);
2340
2341
2342
2/2
✓ Branch 0 taken 268556 times.
✓ Branch 1 taken 16416770 times.
16685326 if(!invisible)
2343
6/6
✓ Branch 0 taken 7409291 times.
✓ Branch 1 taken 9007479 times.
✓ Branch 2 taken 4808578 times.
✓ Branch 3 taken 2600713 times.
✓ Branch 4 taken 183822 times.
✓ Branch 5 taken 4624756 times.
16416770 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_qr(qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2344
2345 // Stone of Agony
2346 16685326 bool agony=false;
2347 16685326 int32_t agonyid = current_item_id(itype_agony);
2348
2349
2/2
✓ Branch 0 taken 268556 times.
✓ Branch 1 taken 16416770 times.
16685326 if(!invisible)
2350 {
2351
2/2
✓ Branch 0 taken 241944 times.
✓ Branch 1 taken 16174826 times.
16416770 if(agonyid>-1)
2352 {
2353 241944 int32_t power=itemsbuf[agonyid].power;
2354 241944 int32_t left=static_cast<int32_t>(x+8-power)&0xF0; // Check top-left pixel of each tile
2355 241944 int32_t right=(static_cast<int32_t>(x+8+power)&0xF0)+16;
2356 241944 int32_t top=static_cast<int32_t>(y+(bigHitbox ? 8 : 12)-power)&0xF0;
2357 241944 int32_t bottom=(static_cast<int32_t>(y+(bigHitbox ? 8 : 12)+power)&0xF0)+16;
2358
2359
2/2
✓ Branch 0 taken 241944 times.
✓ Branch 1 taken 241944 times.
483888 for(int32_t x=left; x<right; x+=16)
2360 {
2361
2/2
✓ Branch 0 taken 241912 times.
✓ Branch 1 taken 241944 times.
483856 for(int32_t y=top; y<bottom; y+=16)
2362 {
2363
4/4
✓ Branch 0 taken 241928 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 241912 times.
✓ Branch 3 taken 16 times.
241944 if(agonyflag(MAPFLAG(x, y)) || agonyflag(MAPCOMBOFLAG(x, y)))
2364 {
2365 32 agony=true;
2366 32 x=right; // Break out of outer loop
2367 32 break;
2368 }
2369 241912 }
2370 241944 }
2371 241944 }
2372
2373 16416770 cs = getFlashingCSet();
2374 16416770 }
2375
2376
5/6
✓ Branch 0 taken 14953412 times.
✓ Branch 1 taken 1731914 times.
✓ Branch 2 taken 14940196 times.
✓ Branch 3 taken 13216 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14940196 times.
16685326 if(attackclk || (action==attacking||action==sideswimattacking))
2377 {
2378 /* Spaghetti code constants!
2379 * - Hero.attack contains a weapon type...
2380 * - which must be converted to an itype...
2381 * - which must be converted to an item ID...
2382 * - which is used to acquire a wpn ID! Aack!
2383 */
2384
8/8
✓ Branch 0 taken 38454 times.
✓ Branch 1 taken 1706676 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 1706648 times.
✓ Branch 4 taken 25729 times.
✓ Branch 5 taken 1680919 times.
✓ Branch 6 taken 64609 times.
✓ Branch 7 taken 1616310 times.
1745130 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : attack==wBugNet ? itype_bugnet : itype_sword);
2385
4/4
✓ Branch 0 taken 487400 times.
✓ Branch 1 taken 1197300 times.
✓ Branch 2 taken 324331 times.
✓ Branch 3 taken 163069 times.
1745130 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
2386 1684700 itemid=vbound(itemid, 0, MAXITEMS-1);
2387 // if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2388
8/8
✓ Branch 0 taken 574637 times.
✓ Branch 1 taken 1110063 times.
✓ Branch 2 taken 574613 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 378210 times.
✓ Branch 5 taken 196403 times.
✓ Branch 6 taken 213725 times.
✓ Branch 7 taken 164485 times.
1684700 if(attackclk>4||attack==wBugNet||(attack==wSword&&game->get_canslash()))
2389 {
2390
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 1323674 times.
1323812 if(attack == wBugNet)
2391 {
2392 138 weapon *w=NULL;
2393 138 bool found = false;
2394
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 132 times.
138 for(int32_t q = 0; q < Lwpns.Count(); ++q)
2395 {
2396 132 w = (weapon*)Lwpns.spr(q);
2397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(w->id == wBugNet)
2398 {
2399 132 found = true;
2400 132 break;
2401 }
2402 }
2403
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 6 times.
138 if(!found)
2404 {
2405
5/10
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
6 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wBugNet,0,0,dir,itemid,getUID(),false,false,true));
2406
2407 6 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2408 6 }
2409 138 positionNet(w, itemid);
2410 138 }
2411
8/8
✓ Branch 0 taken 248408 times.
✓ Branch 1 taken 1075266 times.
✓ Branch 2 taken 230034 times.
✓ Branch 3 taken 18374 times.
✓ Branch 4 taken 215275 times.
✓ Branch 5 taken 14759 times.
✓ Branch 6 taken 229544 times.
✓ Branch 7 taken 1094130 times.
1323674 else if((attack==wSword || attack==wWand || ((attack==wFire || attack==wCByrna) && itemsbuf[itemid].wpn)) && wpnsbuf[itemsbuf[itemid].wpn].tile)
2412 {
2413 // Create a sword weapon at the right spot.
2414 1094130 weapon *w=find_first_wtype(attack==wSword ? wSword : wWand);
2415
2/2
✓ Branch 0 taken 1005337 times.
✓ Branch 1 taken 88793 times.
1094130 if(!w) // Create one if sword nonexistant
2416 {
2417
5/10
✓ Branch 0 taken 88793 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88793 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88793 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88793 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 88793 times.
✗ Branch 9 not taken.
88793 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,(attack==wSword ? wSword : wWand),0,0,dir,itemid,getUID(),false,false,true));
2418 88793 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2419
2420 88793 positionSword(w,itemid);
2421
2422 // Stone of Agony
2423
1/2
✓ Branch 0 taken 88793 times.
✗ Branch 1 not taken.
88793 if(agony)
2424 {
2425 w->y-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,2))?1:0;
2426 }
2427 88793 }
2428
2429 // These are set by positionSword(), above or in checkstab()
2430 1094130 yofs += slashyofs;
2431 1094130 xofs += slashxofs;
2432 1094130 slashyofs = slashxofs = 0;
2433 1094130 }
2434 1323812 }
2435
2436 1684802 if(attackclk<7
2437
4/4
✓ Branch 0 taken 917267 times.
✓ Branch 1 taken 767433 times.
✓ Branch 2 taken 731521 times.
✓ Branch 3 taken 185746 times.
1684700 || (attack==wSword && ((attackclk<(game->get_canslash()?15:13)
2438
4/6
✓ Branch 0 taken 137308 times.
✓ Branch 1 taken 594213 times.
✓ Branch 2 taken 137308 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 137308 times.
731521 || FIXED_Z3_ANIMATION && attackclk<(game->get_canslash()?16:12))
2439
2/2
✓ Branch 0 taken 38044 times.
✓ Branch 1 taken 99264 times.
137308 || (charging>0 && attackclk!=SWORDCHARGEFRAME)))
2440
4/4
✓ Branch 0 taken 304215 times.
✓ Branch 1 taken 24181 times.
✓ Branch 2 taken 292778 times.
✓ Branch 3 taken 11437 times.
323054 || ((attack==wWand || attack==wFire || attack==wCByrna) && attackclk<13)
2441
4/4
✓ Branch 0 taken 29392 times.
✓ Branch 1 taken 299004 times.
✓ Branch 2 taken 50923 times.
✓ Branch 3 taken 248081 times.
328396 || (attack==wHammer && attackclk<=30)
2442
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 247979 times.
299004 || (attack==wBugNet && attackclk<NET_CLK_TOTAL))
2443 {
2444
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 1479767 times.
1480107 if(!invisible)
2445 {
2446 1479767 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimstab:ls_stab, dir, zinit.heroAnimationStyle);
2447
2/4
✓ Branch 0 taken 1479767 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1479767 times.
✗ Branch 3 not taken.
1479767 if (FIXED_Z3_ANIMATION)
2448 {
2449 if (attackclk >= 2) tile += (extend==2?2:1);
2450 if (attackclk >= 13) tile += (extend==2?2:1);
2451 }
2452
2453
14/18
✓ Branch 0 taken 742532 times.
✓ Branch 1 taken 737235 times.
✓ Branch 2 taken 157205 times.
✓ Branch 3 taken 585327 times.
✓ Branch 4 taken 146324 times.
✓ Branch 5 taken 10881 times.
✓ Branch 6 taken 141820 times.
✓ Branch 7 taken 4504 times.
✓ Branch 8 taken 584266 times.
✓ Branch 9 taken 158266 times.
✓ Branch 10 taken 331198 times.
✓ Branch 11 taken 253068 times.
✓ Branch 12 taken 331198 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 331198 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
1479767 if(((game->get_canslash() && (attack==wSword || attack==wWand || attack==wFire || attack==wCByrna)) && itemsbuf[itemid].flags&item_flag4 && (attackclk<7||FIXED_Z3_ANIMATION&&(attackclk < 16))))
2454 {
2455 253068 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2456
2/4
✓ Branch 0 taken 253068 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253068 times.
✗ Branch 3 not taken.
253068 if (FIXED_Z3_ANIMATION)
2457 {
2458 if (attackclk >= 7) tile += (extend==2?2:1);
2459 if (attackclk >= 11) tile += (extend==2?2:1);
2460 if (attackclk >= 14) tile += (extend==2?2:1);
2461 }
2462 253068 }
2463
3/4
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 1479629 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 138 times.
1479767 if (attack==wBugNet && !get_qr(qr_OLD_BUG_NET))
2464 {
2465
6/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 100 times.
✓ Branch 5 taken 62 times.
138 if ((dir == right && (itemsbuf[itemid].flags&item_flag2)) || (dir != right && !(itemsbuf[itemid].flags&item_flag2)))
2466 {
2467
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 32 times.
100 if (attackclk < 9) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2468
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 40 times.
100 if (attackclk > 15) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2469 100 }
2470 else
2471 {
2472
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 16 times.
162 if (attackclk < 9) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2473
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 8 times.
38 if (attackclk > 15) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2474 }
2475 138 }
2476
2477
4/4
✓ Branch 0 taken 64609 times.
✓ Branch 1 taken 1415158 times.
✓ Branch 2 taken 37727 times.
✓ Branch 3 taken 26882 times.
1479767 if((attack==wHammer) && (attackclk<13))
2478 {
2479 26882 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimpound:ls_pound, dir, zinit.heroAnimationStyle);
2480
2/4
✓ Branch 0 taken 26882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26882 times.
✗ Branch 3 not taken.
26882 if (FIXED_Z3_ANIMATION)
2481 {
2482 if (attackclk >= 14) tile += (extend==2?2:1);
2483 if (attackclk >= 16) tile += (extend==2?2:1);
2484 }
2485 26882 }
2486
2487
2/2
✓ Branch 0 taken 987121 times.
✓ Branch 1 taken 492646 times.
1479767 if(useltm)
2488 {
2489
2/2
✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 490806 times.
492646 if ( script_hero_sprite <= 0 ) tile+=getTileModifier();
2490 492646 }
2491
2492 // Stone of Agony
2493
1/2
✓ Branch 0 taken 1479767 times.
✗ Branch 1 not taken.
1479767 if(agony)
2494 {
2495 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2496 }
2497
2498 //Probably what makes Hero flicker, except for the QR check. What makes him flicker when that rule is off?! -Z
2499
2500 //I'm pretty sure he doesn't flicker when the rule is off. Also, take note of the parenthesis after the ! in this if statement; I was blind and didn't see it, and thought this code did something completely different. -Deedee
2501
2/2
✓ Branch 0 taken 12487 times.
✓ Branch 1 taken 1467280 times.
1479767 if (is_hitflickerframe())
2502 {
2503
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12485 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12485 times.
12487 int32_t temp_flicker_color = (game->get_life() > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
2504
2/4
✓ Branch 0 taken 12487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12487 times.
✗ Branch 3 not taken.
12487 if((game->get_spriteflickercolor() || temp_flicker_color) && !superman)
2505 {
2506 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
2507 sprite_flicker_color = temp_flicker_color;
2508 masked_draw(dest);
2509 }
2510 12487 }
2511 else
2512 1467280 masked_draw(dest);
2513
2514 //Prevent flickering -Z
2515
1/2
✓ Branch 0 taken 1479767 times.
✗ Branch 1 not taken.
1479767 if (!getCanFlicker()) masked_draw(dest);
2516 1479767 }
2517
2518
2/2
✓ Branch 0 taken 1415498 times.
✓ Branch 1 taken 64609 times.
1480107 if(attack!=wHammer)
2519 1415498 goto herodraw_end;
2520 64609 }
2521
2522
2/2
✓ Branch 0 taken 64609 times.
✓ Branch 1 taken 247979 times.
312588 if(attack==wHammer) // To do: possibly abstract this out to a positionHammer routine?
2523 {
2524 64609 int32_t wy=1;
2525 64609 int32_t wx=1;
2526 64609 int32_t f=0,t,cs2;
2527 64609 weapon *w=NULL;
2528 64609 bool found = false;
2529
2530
2/2
✓ Branch 0 taken 2255 times.
✓ Branch 1 taken 63240 times.
65495 for(int32_t i=0; i<Lwpns.Count(); i++)
2531 {
2532 63240 w = (weapon*)Lwpns.spr(i);
2533
2534
2/2
✓ Branch 0 taken 886 times.
✓ Branch 1 taken 62354 times.
63240 if(w->id == wHammer)
2535 {
2536 62354 found = true;
2537 62354 break;
2538 }
2539 886 }
2540
2541
2/2
✓ Branch 0 taken 62354 times.
✓ Branch 1 taken 2255 times.
64609 if(!found)
2542 {
2543
5/10
✓ Branch 0 taken 2255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2255 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2255 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2255 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2255 times.
✗ Branch 9 not taken.
2255 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wHammer,0,0,dir,itemid,getUID(),false,false,true));
2544 2255 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2545 2255 found = true;
2546 2255 }
2547
2548 64609 t = w->o_tile;
2549 64609 cs2 = w->o_cset;
2550
2551
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 10368 times.
✓ Branch 2 taken 15134 times.
✓ Branch 3 taken 21126 times.
✓ Branch 4 taken 17981 times.
64609 switch(dir)
2552 {
2553 case up:
2554 10368 wx=-1;
2555 10368 wy=-15;
2556
1/2
✓ Branch 0 taken 10368 times.
✗ Branch 1 not taken.
10368 if (IsSideSwim())wy+=hammer_swim_up_offset;
2557
2558
2/2
✓ Branch 0 taken 4383 times.
✓ Branch 1 taken 5985 times.
10368 if(attackclk>=13)
2559 {
2560 5985 wx-=1;
2561 5985 wy+=1;
2562 5985 ++t;
2563 5985 }
2564
2565
2/2
✓ Branch 0 taken 5061 times.
✓ Branch 1 taken 5307 times.
10368 if(attackclk>=15)
2566 {
2567
1/2
✓ Branch 0 taken 5307 times.
✗ Branch 1 not taken.
5307 if (IsSideSwim())wy-=hammer_swim_up_offset;
2568 5307 ++t;
2569 5307 }
2570
2571 10368 break;
2572
2573 case down:
2574 15134 wx=3;
2575 15134 wy=-14;
2576
1/2
✓ Branch 0 taken 15134 times.
✗ Branch 1 not taken.
15134 if (IsSideSwim())wy+=hammer_swim_down_offset;
2577 15134 t+=3;
2578
2579
2/2
✓ Branch 0 taken 6339 times.
✓ Branch 1 taken 8795 times.
15134 if(attackclk>=13)
2580 {
2581 8795 wy+=16;
2582 8795 ++t;
2583 8795 }
2584
2585
2/2
✓ Branch 0 taken 7346 times.
✓ Branch 1 taken 7788 times.
15134 if(attackclk>=15)
2586 {
2587 7788 wx-=1;
2588 7788 wy+=12;
2589
1/2
✓ Branch 0 taken 7788 times.
✗ Branch 1 not taken.
7788 if (IsSideSwim())wy-=hammer_swim_down_offset;
2590 7788 ++t;
2591 7788 }
2592
2593 15134 break;
2594
2595 case left:
2596 21126 wx=0;
2597 21126 wy=-14;
2598
1/2
✓ Branch 0 taken 21126 times.
✗ Branch 1 not taken.
21126 if (IsSideSwim())wy+=hammer_swim_left_offset;
2599 21126 t+=6;
2600 21126 f=1;
2601
2602
2/2
✓ Branch 0 taken 8777 times.
✓ Branch 1 taken 12349 times.
21126 if(attackclk>=13)
2603 {
2604 12349 wx-=7;
2605 12349 wy+=8;
2606 12349 ++t;
2607 12349 }
2608
2609
2/2
✓ Branch 0 taken 10191 times.
✓ Branch 1 taken 10935 times.
21126 if(attackclk>=15)
2610 {
2611 10935 wx-=8;
2612 10935 wy+=8;
2613
1/2
✓ Branch 0 taken 10935 times.
✗ Branch 1 not taken.
10935 if (IsSideSwim())wy-=hammer_swim_left_offset;
2614 10935 ++t;
2615 10935 }
2616
2617 21126 break;
2618
2619 case right:
2620 17981 wx=0;
2621 17981 wy=-14;
2622
1/2
✓ Branch 0 taken 17981 times.
✗ Branch 1 not taken.
17981 if (IsSideSwim())wy+=hammer_swim_right_offset;
2623 17981 t+=6;
2624
2625
2/2
✓ Branch 0 taken 7383 times.
✓ Branch 1 taken 10598 times.
17981 if(attackclk>=13)
2626 {
2627 10598 wx+=7;
2628 10598 wy+=8;
2629 10598 ++t;
2630 10598 }
2631
2632
2/2
✓ Branch 0 taken 8581 times.
✓ Branch 1 taken 9400 times.
17981 if(attackclk>=15)
2633 {
2634 9400 wx+=8;
2635 9400 wy+=8;
2636
1/2
✓ Branch 0 taken 9400 times.
✗ Branch 1 not taken.
9400 if (IsSideSwim())wy-=hammer_swim_right_offset;
2637 9400 ++t;
2638 9400 }
2639
2640 17981 break;
2641 }
2642
2643
7/8
✓ Branch 0 taken 28062 times.
✓ Branch 1 taken 36547 times.
✓ Branch 2 taken 20878 times.
✓ Branch 3 taken 7184 times.
✓ Branch 4 taken 20878 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4720 times.
✓ Branch 7 taken 16158 times.
64609 if(BSZ || ((isdungeon() && currscr<128) && !get_qr(qr_HERODUNGEONPOSFIX)))
2644 {
2645 52705 wy+=2;
2646 52705 }
2647
2648 // Stone of Agony
2649
1/2
✓ Branch 0 taken 64609 times.
✗ Branch 1 not taken.
64609 if(agony)
2650 {
2651 wy-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2652 }
2653
2654 64609 w->x = x+wx;
2655 64609 w->y = y+wy-(54-yofs)-fakez;
2656 64609 w->z = (z+zofs);
2657 64609 w->tile = t;
2658 64609 w->flip = f;
2659 64609 w->hit_width=20;
2660 64609 w->hit_height=20;
2661
2662
2/2
✓ Branch 0 taken 39107 times.
✓ Branch 1 taken 25502 times.
64609 if(dir>down)
2663 {
2664 39107 w->hit_height-=6;
2665 39107 }
2666 else
2667 {
2668 25502 w->hit_width-=6;
2669 25502 w->hyofs=4;
2670 }
2671
2672 64609 w->power = weaponattackpower(itemid);
2673
2674
7/10
✓ Branch 0 taken 2130 times.
✓ Branch 1 taken 62479 times.
✓ Branch 2 taken 2130 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2130 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 2125 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
64609 if(attackclk==15 && z==0 && fakez==0 && (sideviewhammerpound() || !isSideViewHero()))
2675 {
2676
3/4
✓ Branch 0 taken 2118 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2130 times.
✗ Branch 3 not taken.
2130 sfx(((iswaterex(MAPCOMBO(x+wx+8,y+wy), currmap, currscr, -1, x+wx+8, y+wy, true) || COMBOTYPE(x+wx+8,y+wy)==cSHALLOWWATER) && get_qr(qr_MORESOUNDS)) ? WAV_ZN1SPLASH : itemsbuf[itemid].usesound,pan(x.getInt()));
2677 2130 }
2678
2679 64609 goto herodraw_end;
2680 }
2681 247979 }
2682
2/4
✓ Branch 0 taken 14940196 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14940196 times.
14940196 else if(!charging && !spins) // remove the sword
2683 {
2684
2/2
✓ Branch 0 taken 2942761 times.
✓ Branch 1 taken 14940196 times.
17882957 for(int32_t i=0; i<Lwpns.Count(); i++)
2685 {
2686 2942761 weapon *w = (weapon*)Lwpns.spr(i);
2687
2688
6/6
✓ Branch 0 taken 2941964 times.
✓ Branch 1 taken 797 times.
✓ Branch 2 taken 2940456 times.
✓ Branch 3 taken 1508 times.
✓ Branch 4 taken 31846 times.
✓ Branch 5 taken 2908610 times.
2942761 if(w->id == wSword || w->id == wHammer || w->id==wWand)
2689 34151 w->dead=1;
2690 2942761 }
2691 14940196 }
2692
2693
2/2
✓ Branch 0 taken 251172 times.
✓ Branch 1 taken 14937003 times.
15188175 if(invisible)
2694 {
2695 251172 goto herodraw_end;
2696 }
2697
2698
3/4
✓ Branch 0 taken 14934156 times.
✓ Branch 1 taken 2847 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14934156 times.
14937003 if(action != casting && action != sideswimcasting)
2699 {
2700 // Keep this consistent with checkspecial2, line 7800-ish...
2701
6/6
✓ Branch 0 taken 295974 times.
✓ Branch 1 taken 14638182 times.
✓ Branch 2 taken 285086 times.
✓ Branch 3 taken 10888 times.
✓ Branch 4 taken 12379 times.
✓ Branch 5 taken 272707 times.
14934156 bool inwater = iswaterex(MAPCOMBO(x+4,y+9), currmap, currscr, -1, x+4, y+9, true, false) && iswaterex(MAPCOMBO(x+4,y+15), currmap, currscr, -1, x+4, y+15, true, false) && iswaterex(MAPCOMBO(x+11,y+9), currmap, currscr, -1, x+11, y+9, true, false) && iswaterex(MAPCOMBO(x+11,y+15), currmap, currscr, -1, x+11, y+15, true, false);
2702
2703 14934156 int32_t jumping2 = int32_t(jumping*((zinit.gravity / 100)/16.0));
2704 14934156 bool noliftspr = get_qr(qr_NO_LIFT_SPRITE);
2705 14934156 bool advancetile = script_hero_sprite <= 0;
2706 //if (jumping!=0) al_trace("%d %d %f %d\n",jumping,zinit.gravity,zinit.gravity/16.0,jumping2);
2707
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 8443561 times.
✓ Branch 3 taken 6490595 times.
14934156 switch(zinit.heroAnimationStyle)
2708 {
2709 case las_original: //normal
2710
2/2
✓ Branch 0 taken 3040 times.
✓ Branch 1 taken 8440521 times.
8443561 if(action==drowning)
2711 {
2712
1/2
✓ Branch 0 taken 3040 times.
✗ Branch 1 not taken.
3040 if(inwater)
2713 {
2714 3040 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3040 times.
3040 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2716 3040 }
2717 else
2718 {
2719 goto herodraw_end;
2720 }
2721 3040 }
2722
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 8440265 times.
8440521 else if(action==lavadrowning)
2723 {
2724 256 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
256 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2726 256 }
2727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8440265 times.
8440265 else if(action==sidedrowning)
2728 {
2729 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2730 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2731 }
2732
2/4
✓ Branch 0 taken 8440265 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8440265 times.
8440265 else if (action == sideswimming || action == sideswimhit)
2733 {
2734 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2735
2736 if(lstep>=6)
2737 {
2738 if(dir==up)
2739 {
2740 if(advancetile) ++flip;
2741 }
2742 else
2743 {
2744 if(advancetile) extend==2?tile+=2:++tile;
2745 }
2746 }
2747 }
2748
5/6
✓ Branch 0 taken 8345628 times.
✓ Branch 1 taken 94637 times.
✓ Branch 2 taken 8344807 times.
✓ Branch 3 taken 821 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8344807 times.
8440265 else if(action==swimming || action==swimhit || hopclk==0xFF)
2749 {
2750 95458 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2751
2752
2/2
✓ Branch 0 taken 47669 times.
✓ Branch 1 taken 47789 times.
95458 if(lstep>=6)
2753 {
2754
2/2
✓ Branch 0 taken 9775 times.
✓ Branch 1 taken 38014 times.
47789 if(dir==up)
2755 {
2756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9775 times.
9775 if(advancetile) ++flip;
2757 9775 }
2758 else
2759 {
2760
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38014 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38014 times.
38014 if(advancetile) extend==2?tile+=2:++tile;
2761 }
2762 47789 }
2763
2764
2/2
✓ Branch 0 taken 90255 times.
✓ Branch 1 taken 5203 times.
95458 if(isDiving())
2765 {
2766 5203 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5203 times.
5203 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2768 5203 }
2769 95458 }
2770
3/4
✓ Branch 0 taken 1618 times.
✓ Branch 1 taken 8343189 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1618 times.
8344807 else if(charging > 0 && attack != wHammer)
2771 {
2772 1618 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2773
2774
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 675 times.
1618 if(lstep>=6)
2775 {
2776
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 144 times.
675 if(dir==up)
2777 {
2778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(advancetile) ++flip;
2779 144 }
2780 else
2781 {
2782
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 531 times.
531 if(advancetile) extend==2?tile+=2:++tile;
2783 }
2784 675 }
2785 1618 }
2786
9/12
✓ Branch 0 taken 8342947 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 8342947 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 85805 times.
✓ Branch 5 taken 8257384 times.
✓ Branch 6 taken 71761 times.
✓ Branch 7 taken 14044 times.
✓ Branch 8 taken 71761 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 71761 times.
8343189 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0 && action!=rafting)
2787 {
2788 71761 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71761 times.
71761 if(advancetile) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2790 71761 }
2791
2/2
✓ Branch 0 taken 1890 times.
✓ Branch 1 taken 8269538 times.
8271428 else if(fallclk>0)
2792 {
2793 1890 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1890 times.
1890 if(advancetile) tile+=((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2795 1890 }
2796
5/6
✓ Branch 0 taken 419450 times.
✓ Branch 1 taken 7850088 times.
✓ Branch 2 taken 585 times.
✓ Branch 3 taken 418865 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 585 times.
8269538 else if(!noliftspr&&action==lifting&&isLifting())
2797 {
2798 585 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 585 times.
585 if(script_hero_sprite <= 0)
2800 {
2801 585 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2802 585 auto speed = tliftclk/frames;
2803
1/2
✓ Branch 0 taken 585 times.
✗ Branch 1 not taken.
585 if (speed < 1) speed = 1;
2804 585 auto curframe = (tliftclk - liftclk) / speed;
2805
1/2
✓ Branch 0 taken 585 times.
✗ Branch 1 not taken.
585 if (!tliftclk) curframe = frames - 1;
2806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 585 times.
585 if(unsigned(curframe) < frames)
2807 585 tile += curframe * (extend == 2 ? 2 : 1);
2808 585 }
2809 585 }
2810 else
2811 {
2812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8268953 times.
8268953 if(IsSideSwim())
2813 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2814 else
2815 {
2816
4/4
✓ Branch 0 taken 418865 times.
✓ Branch 1 taken 7850088 times.
✓ Branch 2 taken 410269 times.
✓ Branch 3 taken 8596 times.
8268953 if(!noliftspr&&isLifting())
2817 8596 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2818 8260357 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2819 }
2820
2821
2/2
✓ Branch 0 taken 6133045 times.
✓ Branch 1 taken 2135908 times.
8268953 if(dir>up)
2822 {
2823 6133045 useltm=true;
2824 6133045 shieldModify=true;
2825 6133045 }
2826
2827
3/4
✓ Branch 0 taken 8268953 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4026929 times.
✓ Branch 3 taken 4242024 times.
8268953 if(advancetile && lstep>=6)
2828 {
2829
2/2
✓ Branch 0 taken 1087025 times.
✓ Branch 1 taken 3154999 times.
4242024 if(dir==up)
2830 {
2831 1087025 ++flip;
2832 1087025 }
2833 else
2834 {
2835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3154999 times.
3154999 extend==2?tile+=2:++tile;
2836 }
2837 4242024 }
2838 }
2839
2840 8443561 break;
2841
2842 case las_bszelda: //BS
2843
2/2
✓ Branch 0 taken 2944 times.
✓ Branch 1 taken 6487651 times.
6490595 if(action==drowning)
2844 {
2845
1/2
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
2944 if(inwater)
2846 {
2847 2944 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2944 times.
2944 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2849 2944 }
2850 else
2851 {
2852 goto herodraw_end;
2853 }
2854 2944 }
2855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6487651 times.
6487651 else if (action == sidedrowning)
2856 {
2857 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2858 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2859 }
2860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6487651 times.
6487651 else if(action==lavadrowning)
2861 {
2862 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2863 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2864 }
2865
2/4
✓ Branch 0 taken 6487651 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6487651 times.
6487651 else if (action == sideswimming || action == sideswimhit)
2866 {
2867 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2868
2869 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2870 }
2871
6/6
✓ Branch 0 taken 6426007 times.
✓ Branch 1 taken 61644 times.
✓ Branch 2 taken 6425576 times.
✓ Branch 3 taken 431 times.
✓ Branch 4 taken 157 times.
✓ Branch 5 taken 6425419 times.
6487651 else if(action==swimming || action==swimhit || hopclk==0xFF)
2872 {
2873
2/2
✓ Branch 0 taken 15239 times.
✓ Branch 1 taken 46993 times.
62232 if (get_qr(qr_COPIED_SWIM_SPRITES))
2874 {
2875 15239 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2876 15239 }
2877 else
2878 {
2879 46993 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2880 }
2881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62232 times.
62232 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2882
2883
2/2
✓ Branch 0 taken 56358 times.
✓ Branch 1 taken 5874 times.
62232 if(isDiving())
2884 {
2885
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 5034 times.
5874 if (get_qr(qr_COPIED_SWIM_SPRITES))
2886 {
2887 840 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2888 840 }
2889 else
2890 {
2891 5034 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2892 }
2893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5874 times.
5874 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2894 5874 }
2895 62232 }
2896
3/4
✓ Branch 0 taken 32285 times.
✓ Branch 1 taken 6393134 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32285 times.
6425419 else if(charging > 0 && attack != wHammer)
2897 {
2898 32285 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32285 times.
32285 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2900 32285 }
2901
8/10
✓ Branch 0 taken 6374089 times.
✓ Branch 1 taken 19045 times.
✓ Branch 2 taken 6374089 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18002 times.
✓ Branch 5 taken 6375132 times.
✓ Branch 6 taken 11530 times.
✓ Branch 7 taken 6472 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 11530 times.
6393134 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2902 {
2903 11530 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2904
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 11461 times.
11530 if(advancetile) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2905 11530 }
2906
2/2
✓ Branch 0 taken 1890 times.
✓ Branch 1 taken 6379714 times.
6381604 else if(fallclk>0)
2907 {
2908 1890 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1890 times.
1890 if(advancetile) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2910 1890 }
2911
5/6
✓ Branch 0 taken 402185 times.
✓ Branch 1 taken 5977529 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 401806 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
6379714 else if(!noliftspr&&action==lifting&&isLifting())
2912 {
2913 379 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 379 times.
379 if(script_hero_sprite <= 0)
2915 {
2916 379 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2917 379 auto speed = tliftclk/frames;
2918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 379 times.
379 if (speed < 1) speed = 1;
2919 379 auto curframe = (tliftclk - liftclk) / speed;
2920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 379 times.
379 if (!tliftclk) curframe = frames - 1;
2921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 379 times.
379 if(unsigned(curframe) < frames)
2922 379 tile += curframe * (extend == 2 ? 2 : 1);
2923 379 }
2924 379 }
2925 else
2926 {
2927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6379335 times.
6379335 if(IsSideSwim())
2928 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2929 else
2930 {
2931
4/4
✓ Branch 0 taken 401806 times.
✓ Branch 1 taken 5977529 times.
✓ Branch 2 taken 399394 times.
✓ Branch 3 taken 2412 times.
6379335 if(!noliftspr&&isLifting())
2932 2412 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2933 6376923 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2934 }
2935
2936
2/2
✓ Branch 0 taken 1824846 times.
✓ Branch 1 taken 4554489 times.
6379335 if(dir > up)
2937 {
2938 4554489 useltm=true;
2939 4554489 shieldModify=true;
2940 4554489 }
2941
2/2
✓ Branch 0 taken 6489 times.
✓ Branch 1 taken 6372846 times.
6379335 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2942 }
2943
2944 6490595 break;
2945
2946 case las_zelda3slow: //8-frame Zelda 3 (slow)
2947 case las_zelda3: //8-frame Zelda 3
2948 if(action == drowning)
2949 {
2950 if(inwater)
2951 {
2952 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2953 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2954 }
2955 else
2956 {
2957 goto herodraw_end;
2958 }
2959 }
2960 else if(action == lavadrowning)
2961 {
2962 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2963 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2964
2965 }
2966 else if(action == sidedrowning)
2967 {
2968 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2969 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2970 }
2971 else if (action == sideswimming || action == sideswimhit)
2972 {
2973 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2974
2975 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2976 }
2977 else if(action == swimming || action==swimhit || hopclk==0xFF)
2978 {
2979 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2980 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2981
2982 if(isDiving())
2983 {
2984 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2985 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2986 }
2987 }
2988 else if(charging > 0 && attack != wHammer)
2989 {
2990 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2991 if (script_hero_sprite <= 0 ) tile+=(extend==2?2:1);
2992 //int32_t l=hero_count/hero_animation_speed;
2993 int32_t l=(hero_count/hero_animation_speed)&15;
2994 //int32_t l=((p[lt_clock]/hero_animation_speed)&15);
2995 l-=((l>3)?1:0)+((l>12)?1:0);
2996 if (script_hero_sprite <= 0 ) tile+=(l/2)*(extend==2?2:1);
2997 }
2998 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2999 {
3000 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
3001 if (script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
3002 }
3003 else if(fallclk>0)
3004 {
3005 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
3006 if (script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
3007 }
3008 else if(!noliftspr&&action==lifting&&isLifting())
3009 {
3010 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
3011 if(script_hero_sprite <= 0)
3012 {
3013 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
3014 auto speed = tliftclk/frames;
3015 if (speed < 1) speed = 1;
3016 auto curframe = (tliftclk-liftclk)/speed;
3017 if (!tliftclk) curframe = frames - 1;
3018 if(unsigned(curframe) < frames)
3019 tile += curframe * (extend == 2 ? 2 : 1);
3020 }
3021 }
3022 else
3023 {
3024 if(IsSideSwim())
3025 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
3026 else
3027 {
3028 if(!noliftspr&&isLifting())
3029 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
3030 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
3031 }
3032
3033 if(advancetile && (action == walking || action == climbcoverbottom || action == climbcovertop))
3034 {
3035 tile += (extend == 2 ? 2 : 1);
3036 }
3037
3038 if(dir>up)
3039 {
3040 useltm=true;
3041 shieldModify=true;
3042 }
3043
3044 if(advancetile && (action == walking || action == hopping || action == climbcoverbottom || action == climbcovertop))
3045 {
3046 //tile+=(extend==2?2:1);
3047 //tile+=(((active_count>>2)%8)*(extend==2?2:1));
3048 int32_t l = hero_count / hero_animation_speed;
3049 l -= ((l > 3) ? 1 : 0) + ((l > 12) ? 1 : 0);
3050 tile += (l / 2) * (extend == 2 ? 2 : 1);
3051 }
3052 }
3053
3054 break;
3055
3056 default:
3057 break;
3058 }
3059 14934156 }
3060
3061
6/6
✓ Branch 0 taken 6689403 times.
✓ Branch 1 taken 8247600 times.
✓ Branch 2 taken 4246459 times.
✓ Branch 3 taken 2442944 times.
✓ Branch 4 taken 170841 times.
✓ Branch 5 taken 4075618 times.
14937003 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_qr(qr_HERODUNGEONPOSFIX)) ? 2 : 0);
3062
3063
2/2
✓ Branch 0 taken 14933699 times.
✓ Branch 1 taken 3304 times.
14937003 if(action==won)
3064 {
3065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3304 times.
3304 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - 2;
3066 3304 }
3067
3068
4/4
✓ Branch 0 taken 14781907 times.
✓ Branch 1 taken 155096 times.
✓ Branch 2 taken 92822 times.
✓ Branch 3 taken 14689085 times.
14937003 if(action==landhold1 || action==landhold2)
3069 {
3070 247918 useltm=(get_qr(qr_EXPANDEDLTM) != 0);
3071
6/6
✓ Branch 0 taken 106761 times.
✓ Branch 1 taken 141157 times.
✓ Branch 2 taken 80905 times.
✓ Branch 3 taken 25856 times.
✓ Branch 4 taken 14607 times.
✓ Branch 5 taken 66298 times.
247918 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_qr(qr_HERODUNGEONPOSFIX)) ? 2 : 0);
3072 247918 herotile(&tile, &flip, &extend, (action==landhold1)?ls_landhold1:ls_landhold2, dir, zinit.heroAnimationStyle);
3073 247918 }
3074
4/4
✓ Branch 0 taken 14687730 times.
✓ Branch 1 taken 1355 times.
✓ Branch 2 taken 859 times.
✓ Branch 3 taken 14686871 times.
14689085 else if(action==waterhold1 || action==waterhold2)
3075 {
3076 2214 useltm=(get_qr(qr_EXPANDEDLTM) != 0);
3077 2214 herotile(&tile, &flip, &extend, (action==waterhold1)?ls_waterhold1:ls_waterhold2, dir, zinit.heroAnimationStyle);
3078 2214 }
3079
2/4
✓ Branch 0 taken 14686871 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14686871 times.
14686871 else if(action==sidewaterhold1 || action==sidewaterhold2)
3080 {
3081 useltm=(get_qr(qr_EXPANDEDLTM) != 0);
3082 herotile(&tile, &flip, &extend, (action==sidewaterhold1)?ls_sidewaterhold1:ls_sidewaterhold2, dir, zinit.heroAnimationStyle);
3083 }
3084
3085
3/4
✓ Branch 0 taken 14934156 times.
✓ Branch 1 taken 2847 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14934156 times.
14937003 if(action!=casting && action!=sideswimcasting)
3086 {
3087
2/2
✓ Branch 0 taken 2633095 times.
✓ Branch 1 taken 12301061 times.
14934156 if(useltm)
3088 {
3089
2/2
✓ Branch 0 taken 6558 times.
✓ Branch 1 taken 12294503 times.
12301061 if (script_hero_sprite <= 0 ) tile+=getTileModifier();
3090 12301061 }
3091 14934156 }
3092
3093 // Stone of Agony
3094
2/2
✓ Branch 0 taken 14936971 times.
✓ Branch 1 taken 32 times.
14937003 if(agony)
3095 {
3096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
3097 32 }
3098
3099
2/2
✓ Branch 0 taken 63499 times.
✓ Branch 1 taken 14873504 times.
14937003 if(is_hitflickerframe())
3100 {
3101
4/6
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 63318 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 63318 times.
63499 int32_t temp_flicker_color = (game->get_life() > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
3102
2/4
✓ Branch 0 taken 63499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63499 times.
✗ Branch 3 not taken.
63499 if((game->get_spriteflickercolor() || temp_flicker_color) && !superman)
3103 {
3104 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
3105 sprite_flicker_color = temp_flicker_color;
3106 masked_draw(dest);
3107 }
3108 63499 }
3109 else
3110 14873504 masked_draw(dest);
3111
3112 //draw held items after Hero so they don't go behind his head
3113
4/4
✓ Branch 0 taken 14781907 times.
✓ Branch 1 taken 155096 times.
✓ Branch 2 taken 92822 times.
✓ Branch 3 taken 14689085 times.
14937003 if(action==landhold1 || action==landhold2)
3114 {
3115
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 247896 times.
247918 if(holditem > -1)
3116 {
3117
2/2
✓ Branch 0 taken 136407 times.
✓ Branch 1 taken 111489 times.
247896 if(get_qr(qr_HOLDITEMANIMATION))
3118 {
3119 136407 putitem2(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
3120 136407 }
3121 else
3122 {
3123 111489 putitem(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem);
3124 }
3125 247896 }
3126 247918 }
3127
4/4
✓ Branch 0 taken 14687730 times.
✓ Branch 1 taken 1355 times.
✓ Branch 2 taken 859 times.
✓ Branch 3 taken 14686871 times.
14689085 else if(action==waterhold1 || action==waterhold2)
3128 {
3129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2214 times.
2214 if(holditem > -1)
3130 {
3131
2/2
✓ Branch 0 taken 1562 times.
✓ Branch 1 taken 652 times.
2214 if(get_qr(qr_HOLDITEMANIMATION))
3132 {
3133 1562 putitem2(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
3134 1562 }
3135 else
3136 {
3137 652 putitem(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem);
3138 }
3139 2214 }
3140 2214 }
3141
2/4
✓ Branch 0 taken 14686871 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14686871 times.
14686871 else if(action==sidewaterhold1 || action==sidewaterhold2) //!DIMITODO: Check to see if this looks right or if it needs waterhold's offset.
3142 {
3143 if(holditem > -1)
3144 {
3145 if(get_qr(qr_HOLDITEMANIMATION))
3146 {
3147 putitem2(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
3148 }
3149 else
3150 {
3151 putitem(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem);
3152 }
3153 }
3154 }
3155
4/4
✓ Branch 0 taken 23254 times.
✓ Branch 1 taken 14913749 times.
✓ Branch 2 taken 5125 times.
✓ Branch 3 taken 18129 times.
14937003 if(fairyclk==0||(get_qr(qr_NOHEARTRING)))
3156 {
3157 14918874 goto herodraw_end;
3158 }
3159
3160 18129 double a2 = fairyclk*4.5 + 90;
3161 18129 int32_t hearts=0;
3162 18129 int32_t htile = 2;
3163
3164 18129 do
3165 {
3166 110312 int32_t nx=125;
3167
3168
2/2
✓ Branch 0 taken 64232 times.
✓ Branch 1 taken 46080 times.
110312 if(get_qr(qr_HEARTRINGFIX))
3169 {
3170 46080 nx=x;
3171 46080 }
3172
3173 110312 int32_t ny=88;
3174
3175
2/2
✓ Branch 0 taken 64232 times.
✓ Branch 1 taken 46080 times.
110312 if(get_qr(qr_HEARTRINGFIX))
3176 {
3177 46080 ny=y;
3178 46080 }
3179
3180 110312 int32_t tx = zc::math::CosD(a2)*53 +nx;
3181 110312 int32_t ty = -zc::math::SinD(a2)*53 +ny+playing_field_offset;
3182 110312 overtile8(dest,htile,tx,ty,1,0);
3183 110312 a2-=45;
3184 110312 ++hearts;
3185
2/2
✓ Branch 0 taken 92183 times.
✓ Branch 1 taken 18129 times.
220624 }
3186
2/2
✓ Branch 0 taken 9920 times.
✓ Branch 1 taken 100392 times.
110312 while(a2>90 && hearts<8);
3187 18129 }
3188 herodraw_end:
3189 16684817 xofs=oxofs;
3190 16684817 yofs=oyofs;
3191 16684817 do_primitives(dest, SPLAYER_PLAYER_DRAW, tmpscr, 0, playing_field_offset);
3192 16684817 }
3193
3194 16340784 void HeroClass::masked_draw(BITMAP* dest)
3195 {
3196 // The first sprite::draw in this function uses sprite_flicker_color
3197 // This is intended to be the player, handle this if this changes. -Moosh
3198 16340784 zfix lz, lfz;
3199
2/2
✓ Branch 0 taken 16328812 times.
✓ Branch 1 taken 11972 times.
16340784 if(lift_wpn)
3200 {
3201 11972 lz = lift_wpn->z;
3202 11972 lfz = lift_wpn->fakez;
3203 11972 }
3204
3205
12/12
✓ Branch 0 taken 6912581 times.
✓ Branch 1 taken 9428203 times.
✓ Branch 2 taken 6666363 times.
✓ Branch 3 taken 246218 times.
✓ Branch 4 taken 6573166 times.
✓ Branch 5 taken 93197 times.
✓ Branch 6 taken 6478852 times.
✓ Branch 7 taken 94314 times.
✓ Branch 8 taken 6341505 times.
✓ Branch 9 taken 137347 times.
✓ Branch 10 taken 6464406 times.
✓ Branch 11 taken 201957 times.
16340784 if(isdungeon() && currscr<128 && (x<16 || x>224 || y<18 || y>146) && !get_qr(qr_FREEFORM))
3206 {
3207 // clip under doorways
3208 201957 BITMAP *sub=create_sub_bitmap(dest,16,playing_field_offset+16,224,144);
3209
3210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201957 times.
201957 if(sub!=NULL)
3211 {
3212 201957 yofs -= (playing_field_offset+16);
3213 201957 xofs -= 16;
3214 201957 sprite::draw(sub);
3215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201957 times.
201957 if(lift_wpn)
3216 {
3217 handle_lift(false);
3218 bool shad = lift_wpn->has_shadow;
3219 lift_wpn->has_shadow = false;
3220 lift_wpn->z += z;
3221 lift_wpn->fakez += fakez;
3222 lift_wpn->draw(sub);
3223 lift_wpn->has_shadow = shad;
3224 }
3225 201957 prompt_draw(sub);
3226 201957 xofs+=16;
3227 201957 yofs += (playing_field_offset+16);
3228 201957 destroy_bitmap(sub);
3229 201957 }
3230 201957 }
3231 else
3232 {
3233 16138827 sprite::draw(dest);
3234
2/2
✓ Branch 0 taken 16126855 times.
✓ Branch 1 taken 11972 times.
16138827 if(lift_wpn)
3235 {
3236 11972 handle_lift(false);
3237 11972 bool shad = lift_wpn->has_shadow;
3238 11972 lift_wpn->has_shadow = false;
3239 11972 lift_wpn->z += z;
3240 11972 lift_wpn->fakez += fakez;
3241 11972 lift_wpn->draw(dest);
3242 11972 lift_wpn->has_shadow = shad;
3243 11972 }
3244 16138827 prompt_draw(dest);
3245 }
3246
3247
2/2
✓ Branch 0 taken 16328812 times.
✓ Branch 1 taken 11972 times.
16340784 if(lift_wpn)
3248 {
3249 11972 lift_wpn->z = lz;
3250 11972 lift_wpn->fakez = lfz;
3251 11972 }
3252 16340784 return;
3253 }
3254 16340784 void HeroClass::prompt_draw(BITMAP* dest)
3255 {
3256
2/2
✓ Branch 0 taken 16331171 times.
✓ Branch 1 taken 9613 times.
16340784 if(!prompt_combo) return;
3257 9613 int32_t sx = real_x(x+xofs+prompt_x);
3258 9613 int32_t sy = real_y(y + yofs + prompt_y) - real_z(z + zofs);
3259 9613 sy -= fake_z(fakez);
3260 9613 overcombo(dest, sx, sy, prompt_combo, prompt_cset);
3261 9613 return;
3262 16340784 }
3263
3264 21261 void collectitem_script(int32_t id)
3265 {
3266
2/2
✓ Branch 0 taken 20964 times.
✓ Branch 1 taken 297 times.
21261 if(itemsbuf[id].collect_script)
3267 {
3268 //clear item script stack.
3269 297 FFCore.ref(ScriptType::Item, -id).Clear();
3270
3271
2/6
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 297 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
297 if ( id > 0 && !(FFCore.doscript(ScriptType::Item, -id) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) ) //No collect script on item 0.
3272 {
3273 297 int i = -id;
3274 297 FFCore.reset_script_engine_data(ScriptType::Item, i);
3275 297 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].collect_script, i);
3276 297 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
3277 297 }
3278 else if (id == 0 && !(FFCore.doscript(ScriptType::Item, -id) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING))) //item 0
3279 {
3280 int i = COLLECT_SCRIPT_ITEM_ZERO;
3281 FFCore.reset_script_engine_data(ScriptType::Item, i);
3282 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].collect_script, i);
3283 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
3284 }
3285 //runningItemScripts[id] = 0;
3286 297 }
3287 21261 }
3288 2039 void passiveitem_script(int32_t id, bool doRun = false)
3289 {
3290 //Passive item scripts on colelction
3291
3/6
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 1979 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2039 if(itemsbuf[id].script && ( (itemsbuf[id].flags&item_passive_script) && (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) ))
3292 {
3293 FFCore.reset_script_engine_data(ScriptType::Item, id);
3294
3295 if(get_qr(qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
3296 && current_item(itemsbuf[id].family) > itemsbuf[id].fam_type)
3297 {
3298 FFCore.doscript(ScriptType::Item, id) = false;
3299 return;
3300 }
3301 if(doRun)
3302 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].script, id);
3303 }
3304 2039 }
3305
3306 // separate case for sword/wand/hammer/slashed weapons only
3307 // the main weapon checking is in the global function check_collisions()
3308 14168556 bool HeroClass::checkstab()
3309 {
3310
14/14
✓ Branch 0 taken 12548817 times.
✓ Branch 1 taken 1619739 times.
✓ Branch 2 taken 364352 times.
✓ Branch 3 taken 1255387 times.
✓ Branch 4 taken 338883 times.
✓ Branch 5 taken 25469 times.
✓ Branch 6 taken 274524 times.
✓ Branch 7 taken 64359 times.
✓ Branch 8 taken 274496 times.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 253177 times.
✓ Branch 11 taken 21319 times.
✓ Branch 12 taken 374173 times.
✓ Branch 13 taken 992389 times.
14168556 if(action!=attacking && action!=sideswimattacking || (attack!=wSword && attack!=wWand && attack!=wHammer && attack!=wCByrna && attack!=wFire && attack != wBugNet)
3311 1619739 || (attackclk<=4))
3312 13176167 return false;
3313
3314 992389 weapon *w=NULL;
3315
3316 992389 int32_t wx=0,wy=0,wz=0,wxsz=0,wysz=0;
3317 992389 bool found = false;
3318 992389 int32_t melee_weapon_index = 0;
3319 992389 int32_t parentitem=-1;
3320 992389 weapon* meleeweap = nullptr;
3321
2/2
✓ Branch 0 taken 60613 times.
✓ Branch 1 taken 1102826 times.
1163439 for(int32_t i=0; i<Lwpns.Count(); i++)
3322 {
3323 1102826 w = (weapon*)Lwpns.spr(i);
3324
3325
6/6
✓ Branch 0 taken 1102788 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 19001 times.
✓ Branch 3 taken 1083787 times.
✓ Branch 4 taken 171050 times.
✓ Branch 5 taken 931776 times.
1102826 if(w->id == (attack==wCByrna || attack==wFire ? wWand : attack)) // Kludge: Byrna and Candle sticks are wWand-type.
3326 {
3327 931776 found = true;
3328 931776 melee_weapon_index = i+1;
3329 931776 meleeweap = w;
3330 // Position the sword as Hero slashes with it.
3331
4/4
✓ Branch 0 taken 876400 times.
✓ Branch 1 taken 55376 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 876286 times.
931776 if(w->id!=wHammer&&w->id!=wBugNet)
3332 876286 positionSword(w,w->parentitem);
3333
3334 931776 wx=w->x;
3335 931776 wy=w->y;
3336 931776 wz=w->z;
3337 931776 wxsz = w->hit_width;
3338 931776 wysz = w->hit_height;
3339 931776 parentitem = w->parentitem;
3340 931776 break;
3341 }
3342 171050 }
3343
3344
6/6
✓ Branch 0 taken 904075 times.
✓ Branch 1 taken 88314 times.
✓ Branch 2 taken 134885 times.
✓ Branch 3 taken 769190 times.
✓ Branch 4 taken 39264 times.
✓ Branch 5 taken 95621 times.
992389 if(attack==wSword && attackclk>=14 && charging==0)
3345 95621 return false;
3346
3347
2/2
✓ Branch 0 taken 836155 times.
✓ Branch 1 taken 60613 times.
896768 if(!found)
3348 60613 return false;
3349
3350
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 835732 times.
836155 if(attack == wFire)
3351 423 return false;
3352
3353
2/2
✓ Branch 0 taken 780356 times.
✓ Branch 1 taken 55376 times.
835732 if(attack==wHammer)
3354 {
3355
2/2
✓ Branch 0 taken 21946 times.
✓ Branch 1 taken 33430 times.
55376 if(attackclk<15)
3356 {
3357
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3427 times.
✓ Branch 2 taken 5263 times.
✓ Branch 3 taken 7197 times.
✓ Branch 4 taken 6059 times.
21946 switch(w->dir)
3358 {
3359 case up:
3360 3427 wx=x-1;
3361 3427 wy=y-4;
3362 3427 break;
3363
3364 case down:
3365 5263 wx=x+8;
3366 5263 wy=y+28;
3367 5263 break; // This is consistent with 2.10
3368
3369 case left:
3370 7197 wx=x-13;
3371 7197 wy=y+14;
3372 7197 break;
3373
3374 case right:
3375 6059 wx=x+21;
3376 6059 wy=y+14;
3377 6059 break;
3378 }
3379
3380
6/8
✓ Branch 0 taken 2170 times.
✓ Branch 1 taken 19776 times.
✓ Branch 2 taken 2170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 2165 times.
21946 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
3381 {
3382 //decorations.add(new dHammerSmack((zfix)wx, (zfix)wy, dHAMMERSMACK, 0));
3383 /* The hammer smack sprites weren't being positioned properly if Hero changed directions on the same frame that they are created.
3384 switch(dir)
3385 {
3386 case up:
3387 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
3388 break;
3389
3390 case down:
3391 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
3392 break;
3393
3394 case left:
3395 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
3396 break;
3397
3398 case right:
3399 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
3400 break;
3401 }
3402 */
3403 2165 }
3404
3405 21946 return false;
3406 }
3407
2/2
✓ Branch 0 taken 31300 times.
✓ Branch 1 taken 2130 times.
33430 else if(attackclk==15)
3408 {
3409 // Hammer's reach needs adjusted slightly for backward compatibility
3410
2/2
✓ Branch 0 taken 1793 times.
✓ Branch 1 taken 337 times.
2130 if(w->dir==up)
3411 337 w->hyofs-=1;
3412
2/2
✓ Branch 0 taken 1097 times.
✓ Branch 1 taken 696 times.
1793 else if(w->dir==left)
3413 696 w->hxofs-=2;
3414 2130 }
3415 33430 }
3416
3417 // The return of Spaghetti Code Constants!
3418
6/6
✓ Branch 0 taken 16297 times.
✓ Branch 1 taken 797489 times.
✓ Branch 2 taken 763927 times.
✓ Branch 3 taken 33562 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 33544 times.
813786 int32_t itype = (attack==wWand ? itype_wand : attack==wSword ? itype_sword : attack==wCByrna ? itype_cbyrna : attack==wBugNet ? itype_bugnet : itype_hammer);
3419
4/4
✓ Branch 0 taken 80798 times.
✓ Branch 1 taken 732988 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 80770 times.
813786 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
3420 813786 itemid = vbound(itemid, 0, MAXITEMS-1);
3421
3422 // The sword offsets aren't based on anything other than what felt about right
3423 // compared to the NES game and what mostly kept it from hitting things that
3424 // should clearly be out of range. They could probably still use more tweaking.
3425 // Don't use 2.10 for reference; it's pretty far off.
3426 // - Saf
3427
3428
6/6
✓ Branch 0 taken 431413 times.
✓ Branch 1 taken 382373 times.
✓ Branch 2 taken 24750 times.
✓ Branch 3 taken 406663 times.
✓ Branch 4 taken 405892 times.
✓ Branch 5 taken 25521 times.
813786 if(game->get_canslash() && (attack==wSword || attack==wWand) && itemsbuf[itemid].flags & item_flag4)
3429 {
3430
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 70674 times.
✓ Branch 2 taken 89080 times.
✓ Branch 3 taken 125048 times.
✓ Branch 4 taken 121090 times.
405892 switch(w->dir)
3431 {
3432 case up:
3433
2/2
✓ Branch 0 taken 48286 times.
✓ Branch 1 taken 22388 times.
70674 if(attackclk<8)
3434 {
3435 22388 wy-=4;
3436 22388 }
3437
3438 70674 break;
3439
3440 case down:
3441 //if(attackclk<8)
3442 {
3443 89080 wy-=2;
3444 }
3445 89080 break;
3446
3447 case left:
3448
3449 //if(attackclk<8)
3450 {
3451 125048 wx+=2;
3452 }
3453
3454 125048 break;
3455
3456 case right:
3457
3458 //if(attackclk<8)
3459 {
3460 121090 wx-=3;
3461 //wy+=((spins>0 || get_qr(qr_SLASHFLIPFIX)) ? -4 : 4);
3462 }
3463
3464 121090 break;
3465 }
3466 405892 }
3467
3468
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 165130 times.
✓ Branch 2 taken 175929 times.
✓ Branch 3 taken 236576 times.
✓ Branch 4 taken 236151 times.
813786 switch(w->dir)
3469 {
3470 case up:
3471 165130 wx+=2;
3472 165130 break;
3473
3474 case down:
3475 175929 break;
3476
3477 case left:
3478 236576 wy-=3;
3479 236576 break;
3480
3481 case right:
3482 236151 wy-=3;
3483 236151 break;
3484 }
3485
3486 813786 wx+=w->hxofs;
3487 813786 wy+=w->hyofs;
3488 813786 wy-=(w->fakez).getInt();
3489
3490
2/2
✓ Branch 0 taken 807357 times.
✓ Branch 1 taken 3490883 times.
4298240 for(int32_t i=0; i<guys.Count(); i++)
3491 {
3492
2/2
✓ Branch 0 taken 3490788 times.
✓ Branch 1 taken 95 times.
3490883 if(attack==wBugNet) break;
3493 // So that Hero can actually hit peahats while jumping, his weapons' hzsz becomes 16 in midair.
3494
6/6
✓ Branch 0 taken 74095 times.
✓ Branch 1 taken 3416693 times.
✓ Branch 2 taken 73500 times.
✓ Branch 3 taken 595 times.
✓ Branch 4 taken 71823 times.
✓ Branch 5 taken 1677 times.
3491344 if((guys.spr(i)->hit(wx,wy,wz,wxsz,wysz,wz>0?16:8) && ((attack!=wWand && attack!=wHammer && attack!=wCByrna) || !(itemsbuf[itemid].flags & item_flag3)))
3495
5/6
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 2506 times.
✓ Branch 2 taken 3313553 times.
✓ Branch 3 taken 103848 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3417401 times.
3418965 || ((attack==wWand || attack==wCByrna) && guys.spr(i)->hit(wx,wy-8,z,16,24,z>8) && !(itemsbuf[itemid].flags & item_flag3))
3496
4/4
✓ Branch 0 taken 120214 times.
✓ Branch 1 taken 3297187 times.
✓ Branch 2 taken 556 times.
✓ Branch 3 taken 119658 times.
3417401 || (attack==wHammer && guys.spr(i)->hit(wx,wy-8,z,16,24,z>0?16:8) && !(itemsbuf[itemid].flags & item_flag3)))
3497 {
3498 // Checking the whimsical ring for every collision check causes
3499 // an odd bug. It's much more likely to activate on a 0-damage
3500 // weapon, since a 0-damage hit won't make the enemy invulnerable
3501 // to damaging hits in the following frames.
3502
3503 74329 int32_t whimsyid = current_item_id(itype_whimsicalring);
3504
3505 74329 int32_t dmg = weaponattackpower(itemid);
3506
2/2
✓ Branch 0 taken 72420 times.
✓ Branch 1 taken 1909 times.
74329 if(whimsyid>-1)
3507 {
3508
3/4
✓ Branch 0 taken 1909 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1793 times.
✓ Branch 3 taken 116 times.
1909 if(!(zc_oldrand()%zc_max(itemsbuf[whimsyid].misc1,1)))
3509 116 dmg += current_item_power(itype_whimsicalring);
3510 1793 else whimsyid = -1;
3511 1909 }
3512 74329 int32_t atkringid = current_item_id(itype_atkring);
3513
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 74321 times.
74329 if(atkringid>-1)
3514 {
3515 8 dmg *= itemsbuf[atkringid].misc2; //Multiplier
3516 8 dmg += itemsbuf[atkringid].misc1; //Additive
3517 8 }
3518
3519 74329 int32_t h = hit_enemy(i,attack,dmg*game->get_hero_dmgmult(),wx,wy,dir,directWpn,w);
3520 74329 enemy *e = (enemy*)guys.spr(i);
3521
2/2
✓ Branch 0 taken 25189 times.
✓ Branch 1 taken 49140 times.
74329 if (h == -1)
3522 {
3523 49140 e->hitby[HIT_BY_LWEAPON] = melee_weapon_index;
3524 49140 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
3525 49140 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
3526
1/2
✓ Branch 0 taken 49140 times.
✗ Branch 1 not taken.
49140 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
3527 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
3528 49140 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
3529 49140 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
3530 49140 } //temp_hit = true; }
3531 //melee weapons and non-melee weapons both writing to this index may be a problem. It needs to be cleared by something earlier than this check.
3532
3533
4/4
✓ Branch 0 taken 49140 times.
✓ Branch 1 taken 25189 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 49095 times.
74329 if(h<0 && whimsyid>-1)
3534 {
3535 45 sfx(itemsbuf[whimsyid].usesound);
3536 45 }
3537
3538
4/4
✓ Branch 0 taken 63085 times.
✓ Branch 1 taken 11244 times.
✓ Branch 2 taken 62605 times.
✓ Branch 3 taken 480 times.
74329 if(h && charging>0)
3539 {
3540 480 attackclk = SWORDTAPFRAME;
3541 480 spins=0;
3542 480 }
3543
3544
8/8
✓ Branch 0 taken 63085 times.
✓ Branch 1 taken 11244 times.
✓ Branch 2 taken 53449 times.
✓ Branch 3 taken 9636 times.
✓ Branch 4 taken 53415 times.
✓ Branch 5 taken 34 times.
✓ Branch 6 taken 1216 times.
✓ Branch 7 taken 52199 times.
74329 if(h && hclk==0 && inlikelike != 1 && !get_qr(qr_DYING_ENEMIES_IGNORE_STUN))
3545 {
3546
2/2
✓ Branch 0 taken 52042 times.
✓ Branch 1 taken 157 times.
52199 if(GuyHit(i,x+7,y+7-fakez,z,2,2,hzsz)!=-1)
3547 {
3548 157 hithero(i);
3549 157 }
3550 52199 }
3551
3552
2/2
✓ Branch 0 taken 67053 times.
✓ Branch 1 taken 7276 times.
74329 if(h==2)
3553 7276 break;
3554 67053 }
3555 3484454 }
3556
3557
2/2
✓ Branch 0 taken 18938 times.
✓ Branch 1 taken 794734 times.
1628400 if(attack == wBugNet
3558
3/4
✓ Branch 0 taken 813672 times.
✓ Branch 1 taken 1056 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 813672 times.
814728 || (parentitem==-1&&!get_qr(qr_NOITEMMELEE))
3559
1/2
✓ Branch 0 taken 813672 times.
✗ Branch 1 not taken.
813672 || (parentitem>-1&&!(itemsbuf[parentitem].flags & item_flag7)))
3560 {
3561
3/4
✓ Branch 0 taken 795676 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
795790 int32_t bugnetid = attack != wBugNet ? -1 : (parentitem > -1 ? parentitem : current_item_id(itype_bugnet));
3562
2/2
✓ Branch 0 taken 795790 times.
✓ Branch 1 taken 254215 times.
1050005 for(int32_t j=0; j<items.Count(); j++)
3563 {
3564 254215 item* ptr = (item*)items.spr(j);
3565
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 254195 times.
254216 bool dofairy = (attack==wBugNet && itemsbuf[ptr->id].family == itype_fairy)
3566
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
20 && (bugnetid > -1 && !(itemsbuf[bugnetid].flags & item_flag1));
3567
3568
2/4
✓ Branch 0 taken 254215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 254215 times.
✗ Branch 3 not taken.
254215 if((itemsbuf[ptr->id].family == itype_bottlefill || dofairy) && !game->canFillBottle())
3569 continue; //No picking these up unless you have a bottle to fill!
3570
5/6
✓ Branch 0 taken 254188 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 46889 times.
✓ Branch 3 taken 207299 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 46889 times.
254215 if((ptr->pickup & ipCANGRAB) || (ptr->pickup & ipTIMER) || dofairy)
3571 {
3572
7/8
✓ Branch 0 taken 207299 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 96779 times.
✓ Branch 3 taken 110520 times.
✓ Branch 4 taken 110547 times.
✓ Branch 5 taken 96779 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 110547 times.
207326 if(((ptr->pickup & ipCANGRAB) || ptr->clk2 >= 32 || dofairy) && !ptr->fallclk && !ptr->drownclk)
3573 {
3574
6/6
✓ Branch 0 taken 103623 times.
✓ Branch 1 taken 6924 times.
✓ Branch 2 taken 981 times.
✓ Branch 3 taken 102642 times.
✓ Branch 4 taken 103608 times.
✓ Branch 5 taken 6939 times.
214167 if(ptr->hit(wx,wy,z,wxsz,wysz,1) || (attack==wWand && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1))
3575
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 978 times.
✓ Branch 2 taken 100869 times.
✓ Branch 3 taken 2751 times.
103623 || (attack==wHammer && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1)))
3576 {
3577 6939 int32_t pickup = ptr->pickup;
3578 6939 int32_t id2 = ptr->id;
3579 6939 int32_t pstr = ptr->pstring;
3580 6939 int32_t pstr_flags = ptr->pickup_string_flags;
3581
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6938 times.
6939 if(!dofairy)
3582 {
3583 6938 std::vector<int32_t> &ev = FFCore.eventData;
3584 6938 ev.clear();
3585 6938 ev.push_back(id2*10000);
3586 6938 ev.push_back(pickup*10000);
3587 6938 ev.push_back(pstr*10000);
3588 6938 ev.push_back(pstr_flags*10000);
3589 6938 ev.push_back(0);
3590 6938 ev.push_back(ptr->getUID());
3591 6938 ev.push_back(GENEVT_ICTYPE_MELEE*10000);
3592 6938 ev.push_back(w->getUID());
3593
3594 6938 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
3595 6938 bool nullify = ev[4] != 0;
3596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6938 times.
6938 if(nullify) continue;
3597 6938 id2 = ev[0]/10000;
3598 6938 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
3599 6938 pstr = ev[2] / 10000;
3600 6938 pstr_flags = ev[3] / 10000;
3601 6938 }
3602
3603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6939 times.
6939 if(pickup&ipONETIME) // set mITEM for one-time-only items
3604 setmapflag(mITEM);
3605
1/2
✓ Branch 0 taken 6939 times.
✗ Branch 1 not taken.
6939 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
3606 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
3607
3608
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6939 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6939 if(ptr->pickupexstate > -1 && ptr->pickupexstate < 32)
3609 setxmapflag(1<<ptr->pickupexstate);
3610
1/2
✓ Branch 0 taken 6939 times.
✗ Branch 1 not taken.
6939 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
3611 {
3612 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
3613 hidden_entrance(0, true, false, -5);
3614 }
3615 //!DIMI
3616
3617
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6938 times.
6939 if(dofairy)
3618 {
3619 1 game->fillBottle(itemsbuf[ptr->id].misc4);
3620 1 }
3621 else
3622 {
3623 6938 collectitem_script(id2);
3624
3625 6938 getitem(id2, ptr->noSound, true);
3626 }
3627 6939 items.del(j);
3628
3629
2/2
✓ Branch 0 taken 7995 times.
✓ Branch 1 taken 6939 times.
14934 for(int32_t i=0; i<Lwpns.Count(); i++)
3630 {
3631 7995 weapon *w2 = (weapon*)Lwpns.spr(i);
3632
3633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7995 times.
7995 if(w2->dragging==j)
3634 {
3635 w2->dragging=-1;
3636 }
3637
1/2
✓ Branch 0 taken 7995 times.
✗ Branch 1 not taken.
7995 else if(w2->dragging>j)
3638 {
3639 w2->dragging-=1;
3640 }
3641 7995 }
3642
3643
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6939 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6939 if ( (pstr > 0 && pstr < msg_count) )
3644 {
3645 if ( ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
3646 {
3647 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) )
3648 FFCore.SetItemMessagePlayed(id2);
3649 donewmsg(pstr);
3650 break;
3651 }
3652 }
3653
3654 6939 --j;
3655 6939 }
3656 110547 }
3657 207326 }
3658 254215 }
3659 795790 }
3660
3661
4/4
✓ Branch 0 taken 813768 times.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 813654 times.
814728 if(attack==wCByrna || attack==wBugNet)
3662 1074 return false;
3663
3664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 813654 times.
813654 if(meleeweap->no_triggers())
3665 return false;
3666
3667
2/2
✓ Branch 0 taken 763927 times.
✓ Branch 1 taken 49727 times.
813654 if(attack==wSword)
3668 {
3669
2/2
✓ Branch 0 taken 677792 times.
✓ Branch 1 taken 86135 times.
763927 if(attackclk == 6)
3670 {
3671
2/2
✓ Branch 0 taken 15159760 times.
✓ Branch 1 taken 86135 times.
15245895 for(int32_t q=0; q<176; q++)
3672 {
3673 15159760 set_bit(screengrid,q,0);
3674 15159760 set_bit(screengrid_layer[0],q,0);
3675 15159760 set_bit(screengrid_layer[1],q,0);
3676 15159760 }
3677
3678
2/2
✓ Branch 0 taken 1378160 times.
✓ Branch 1 taken 86135 times.
1464295 for(dword q = MAXFFCS/8; q > 0; --q)
3679 1378160 ffcgrid[q-1] = 0;
3680 86135 }
3681
3682
4/4
✓ Branch 0 taken 156755 times.
✓ Branch 1 taken 607172 times.
✓ Branch 2 taken 72500 times.
✓ Branch 3 taken 84255 times.
763927 if(dir==up && ((x.getInt()&15)==0))
3683 {
3684 72500 check_slash_block(wx,wy);
3685 72500 check_slash_block(wx,wy+8);
3686
3687 //layers
3688 72500 check_slash_block_layer(wx,wy,1);
3689 72500 check_slash_block_layer(wx,wy+8,1);
3690 72500 check_slash_block_layer(wx,wy,1);
3691 72500 check_slash_block_layer(wx,wy+8,1);
3692 //2
3693 72500 check_slash_block_layer(wx,wy,2);
3694 72500 check_slash_block_layer(wx,wy+8,2);
3695 72500 check_slash_block_layer(wx,wy,2);
3696 72500 check_slash_block_layer(wx,wy+8,2);
3697 72500 }
3698
8/10
✓ Branch 0 taken 84255 times.
✓ Branch 1 taken 607172 times.
✓ Branch 2 taken 26086 times.
✓ Branch 3 taken 58169 times.
✓ Branch 4 taken 240 times.
✓ Branch 5 taken 25846 times.
✓ Branch 6 taken 240 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 240 times.
691427 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3699 {
3700 84015 check_slash_block(wx,wy);
3701 84015 check_slash_block(wx,wy+8);
3702 84015 check_slash_block(wx+8,wy);
3703 84015 check_slash_block(wx+8,wy+8);
3704 ///layer 1
3705 84015 check_slash_block_layer(wx,wy,1);
3706 84015 check_slash_block_layer(wx,wy+8,1);
3707 84015 check_slash_block_layer(wx+8,wy,1);
3708 84015 check_slash_block_layer(wx+8,wy+8,1);
3709 ///layer 2
3710 84015 check_slash_block_layer(wx,wy,2);
3711 84015 check_slash_block_layer(wx,wy+8,2);
3712 84015 check_slash_block_layer(wx+8,wy,2);
3713 84015 check_slash_block_layer(wx+8,wy+8,2);
3714 84015 }
3715
4/4
✓ Branch 0 taken 165479 times.
✓ Branch 1 taken 598448 times.
✓ Branch 2 taken 86439 times.
✓ Branch 3 taken 79040 times.
763927 if(dir==down && ((x.getInt()&15)==0))
3716 {
3717 79040 check_slash_block(wx,wy+wysz-8);
3718 79040 check_slash_block(wx,wy+wysz);
3719
3720 //layer 1
3721 79040 check_slash_block_layer(wx,wy+wysz-8,1);
3722 79040 check_slash_block_layer(wx,wy+wysz,1);
3723 //layer 2
3724 79040 check_slash_block_layer(wx,wy+wysz-8,2);
3725 79040 check_slash_block_layer(wx,wy+wysz,2);
3726 79040 }
3727
8/10
✓ Branch 0 taken 86439 times.
✓ Branch 1 taken 598448 times.
✓ Branch 2 taken 34908 times.
✓ Branch 3 taken 51531 times.
✓ Branch 4 taken 333 times.
✓ Branch 5 taken 34575 times.
✓ Branch 6 taken 333 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 333 times.
684887 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3728 {
3729 86106 check_slash_block(wx,wy+wysz-8);
3730 86106 check_slash_block(wx,wy+wysz);
3731 86106 check_slash_block(wx+8,wy+wysz-8);
3732 86106 check_slash_block(wx+8,wy+wysz);
3733 //layer 1
3734 86106 check_slash_block_layer(wx,wy+wysz-8,1);
3735 86106 check_slash_block_layer(wx,wy+wysz,1);
3736 86106 check_slash_block_layer(wx+8,wy+wysz-8,1);
3737 86106 check_slash_block_layer(wx+8,wy+wysz,1);
3738 //layer 2
3739 86106 check_slash_block_layer(wx,wy+wysz-8,2);
3740 86106 check_slash_block_layer(wx,wy+wysz,2);
3741 86106 check_slash_block_layer(wx+8,wy+wysz-8,2);
3742 86106 check_slash_block_layer(wx+8,wy+wysz,2);
3743 86106 }
3744
3745
2/2
✓ Branch 0 taken 544407 times.
✓ Branch 1 taken 219520 times.
763927 if(dir==left)
3746 {
3747 219520 check_slash_block(wx,wy+8);
3748 219520 check_slash_block(wx+8,wy+8);
3749 //layer 1
3750 219520 check_slash_block_layer(wx,wy+8,1);
3751 219520 check_slash_block_layer(wx+8,wy+8,1);
3752 //layer 2
3753 219520 check_slash_block_layer(wx,wy+8,2);
3754 219520 check_slash_block_layer(wx+8,wy+8,2);
3755 219520 }
3756
3757
2/2
✓ Branch 0 taken 541754 times.
✓ Branch 1 taken 222173 times.
763927 if(dir==right)
3758 {
3759 222173 check_slash_block(wx+wxsz,wy+8);
3760 222173 check_slash_block(wx+wxsz-8,wy+8);
3761 //layer 1
3762 222173 check_slash_block_layer(wx+wxsz,wy+8,1);
3763 222173 check_slash_block_layer(wx+wxsz-8,wy+8,1);
3764 //layer 2
3765 222173 check_slash_block_layer(wx+wxsz,wy+8,2);
3766 222173 check_slash_block_layer(wx+wxsz-8,wy+8,2);
3767 222173 }
3768 763927 }
3769
2/2
✓ Branch 0 taken 16297 times.
✓ Branch 1 taken 33430 times.
49727 else if(attack==wWand)
3770 {
3771
1/2
✓ Branch 0 taken 16297 times.
✗ Branch 1 not taken.
16297 if(attackclk == 5)
3772 {
3773 for(int32_t q=0; q<176; q++)
3774 {
3775 set_bit(screengrid,q,0);
3776 set_bit(screengrid_layer[0],q,0);
3777 set_bit(screengrid_layer[1],q,0);
3778 }
3779
3780 for(dword q = MAXFFCS/8; q > 0; --q)
3781 ffcgrid[q-1] = 0;
3782 }
3783
3784 // cutable blocks
3785
4/4
✓ Branch 0 taken 3074 times.
✓ Branch 1 taken 13223 times.
✓ Branch 2 taken 1386 times.
✓ Branch 3 taken 1688 times.
16297 if(dir==up && (x.getInt()&15)==0)
3786 {
3787 1386 check_wand_block(wx,wy);
3788 1386 check_wand_block(wx,wy+8);
3789 1386 }
3790
5/10
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 13223 times.
✓ Branch 2 taken 813 times.
✓ Branch 3 taken 875 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 813 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
14911 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3791 {
3792 1688 check_wand_block(wx,wy);
3793 1688 check_wand_block(wx,wy+8);
3794 1688 check_wand_block(wx+8,wy);
3795 1688 check_wand_block(wx+8,wy+8);
3796 1688 }
3797
3798
4/4
✓ Branch 0 taken 2366 times.
✓ Branch 1 taken 13931 times.
✓ Branch 2 taken 1135 times.
✓ Branch 3 taken 1231 times.
16297 if(dir==down && (x.getInt()&15)==0)
3799 {
3800 1231 check_wand_block(wx,wy+wysz-8);
3801 1231 check_wand_block(wx,wy+wysz);
3802 1231 }
3803
5/10
✓ Branch 0 taken 1135 times.
✓ Branch 1 taken 13931 times.
✓ Branch 2 taken 307 times.
✓ Branch 3 taken 828 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 307 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
15066 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3804 {
3805 1135 check_wand_block(wx,wy+wysz-8);
3806 1135 check_wand_block(wx,wy+wysz);
3807 1135 check_wand_block(wx+8,wy+wysz-8);
3808 1135 check_wand_block(wx+8,wy+wysz);
3809 1135 }
3810
3811
2/2
✓ Branch 0 taken 10184 times.
✓ Branch 1 taken 6113 times.
16297 if(dir==left)
3812 {
3813 6113 check_wand_block(wx,y+8);
3814 6113 check_wand_block(wx+8,y+8);
3815 6113 }
3816
3817
2/2
✓ Branch 0 taken 11553 times.
✓ Branch 1 taken 4744 times.
16297 if(dir==right)
3818 {
3819 4744 check_wand_block(wx+wxsz,y+8);
3820 4744 check_wand_block(wx+wxsz-8,y+8);
3821 4744 }
3822 16297 }
3823
4/8
✓ Branch 0 taken 33430 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31300 times.
✓ Branch 3 taken 2130 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31300 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
33430 else if((attack==wHammer) && ((attackclk==15) || ( spins>0 && attackclk >=15 )))
3824 {
3825 // poundable blocks
3826
2/2
✓ Branch 0 taken 374880 times.
✓ Branch 1 taken 2130 times.
377010 for(int32_t q=0; q<176; q++)
3827 {
3828 374880 set_bit(screengrid,q,0);
3829 374880 set_bit(screengrid_layer[0],q,0);
3830 374880 set_bit(screengrid_layer[1],q,0);
3831 374880 }
3832
3833
2/2
✓ Branch 0 taken 34080 times.
✓ Branch 1 taken 2130 times.
36210 for(dword q = MAXFFCS/8; q > 0; --q)
3834 34080 ffcgrid[q-1] = 0;
3835
3836
4/4
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 1792 times.
✓ Branch 2 taken 174 times.
✓ Branch 3 taken 164 times.
2130 if(dir==up && (x.getInt()&15)==0)
3837 {
3838 164 check_pound_block(wx,wy);
3839 164 check_pound_block(wx,wy+8);
3840 164 }
3841
5/10
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 1792 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 127 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1966 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3842 {
3843 174 check_pound_block(wx,wy);
3844 174 check_pound_block(wx,wy+8);
3845 174 check_pound_block(wx+8,wy);
3846 174 check_pound_block(wx+8,wy+8);
3847 174 }
3848
3849
4/4
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 1632 times.
✓ Branch 2 taken 258 times.
✓ Branch 3 taken 240 times.
2130 if(dir==down && (x.getInt()&15)==0)
3850 {
3851 240 check_pound_block(wx,wy+wysz-8);
3852 240 check_pound_block(wx,wy+wysz);
3853 240 }
3854
8/10
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 1632 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 152 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 105 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
1890 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3855 {
3856 257 check_pound_block(wx,wy+wysz-8);
3857 257 check_pound_block(wx,wy+wysz);
3858 257 check_pound_block(wx+8,wy+wysz-8);
3859 257 check_pound_block(wx+8,wy+wysz);
3860 257 }
3861
3862
2/2
✓ Branch 0 taken 1429 times.
✓ Branch 1 taken 701 times.
2130 if(dir==left)
3863 {
3864 701 check_pound_block(wx,y+8);
3865 701 check_pound_block(wx+8,y+8);
3866 701 }
3867
3868
2/2
✓ Branch 0 taken 1537 times.
✓ Branch 1 taken 593 times.
2130 if(dir==right)
3869 {
3870 593 check_pound_block(wx+wxsz,y+8);
3871 593 check_pound_block(wx+wxsz-8,y+8);
3872 593 }
3873 2130 }
3874 31300 else return false;
3875
3876 782354 return true;
3877 14169498 }
3878
3879 4023900 void HeroClass::check_slash_block_layer(int32_t bx, int32_t by, int32_t layer)
3880 {
3881
2/2
✓ Branch 0 taken 3828576 times.
✓ Branch 1 taken 195324 times.
4023900 if(!(get_qr(qr_BUSHESONLAYERS1AND2)))
3882 {
3883 //zprint("bit off\n");
3884 3828576 return;
3885 }
3886 //keep things inside the screen boundaries
3887 195324 bx=vbound(bx, 0, 255);
3888 195324 by=vbound(by, 0, 176);
3889 195324 int32_t fx=vbound(bx, 0, 255);
3890 195324 int32_t fy=vbound(by, 0, 176);
3891 //first things first
3892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 195324 times.
195324 if(attack!=wSword)
3893 return;
3894
3895
4/6
✓ Branch 0 taken 195324 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195324 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1984 times.
✓ Branch 5 taken 20224 times.
217532 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3896
4/4
✓ Branch 0 taken 179972 times.
✓ Branch 1 taken 15352 times.
✓ Branch 2 taken 22208 times.
✓ Branch 3 taken 157764 times.
195324 || (attackclk>SWORDTAPFRAME && tapping))
3897 17336 return;
3898
3899 //find out which combo row/column the coordinates are in
3900 177988 bx &= 0xF0;
3901 177988 by &= 0xF0;
3902
3903
3904 177988 int32_t flag = MAPFLAGL(layer,bx,by);
3905 177988 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
3906 177988 int32_t cid = MAPCOMBOL(layer,bx,by);
3907 177988 int32_t type = combobuf[cid].type;
3908
1/2
✓ Branch 0 taken 177988 times.
✗ Branch 1 not taken.
177988 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3909 type = cNONE;
3910 //zprint("cid is: %d\n", cid);
3911 //zprint("type is: %d\n", type);
3912 177988 int32_t i = (bx>>4) + by;
3913
3914
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 177958 times.
177988 if(i > 175)
3915 30 return;
3916
3917 177958 bool ignorescreen=false;
3918
3919
4/4
✓ Branch 0 taken 177256 times.
✓ Branch 1 taken 702 times.
✓ Branch 2 taken 176971 times.
✓ Branch 3 taken 285 times.
177958 if((get_bit(screengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
3920 177673 return;
3921
3922
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 187 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
285 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3923
3924
3/4
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 188 times.
285 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid_layer[layer-1],i,1);
3925
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if(isCuttableNextType(type))
3926 {
3927 285 FFCore.tempScreens[layer]->data[i]++;
3928 285 }
3929 else
3930 {
3931 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
3932 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
3933 FFCore.tempScreens[layer]->sflag[i] = 0;
3934 }
3935
2/8
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 285 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
285 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3936 {
3937 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3938 sfx(tmpscr->secretsfx);
3939 }
3940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
285 else if(isCuttableItemType(type))
3941 {
3942 285 int32_t it = -1;
3943 285 int32_t thedropset = -1;
3944
3945 //select_dropitem( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) ? (combobuf[MAPCOMBO(bx,by)-1].attributes[1])/10000L : 12, bx, by);
3946
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 254 times.
285 if ( (combobuf[cid].usrflags&cflag2) )
3947 {
3948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(combobuf[cid].usrflags&cflag11)
3949 it = combobuf[cid].attribytes[1];
3950 else
3951 {
3952 31 it = select_dropitem(combobuf[cid].attribytes[1]);
3953 31 thedropset = combobuf[cid].attribytes[1];
3954 }
3955 31 }
3956 else
3957 {
3958 254 it = select_dropitem(12);
3959 254 thedropset = 12;
3960 }
3961
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 96 times.
285 if(it!=-1)
3962 {
3963
4/8
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
96 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3964 96 itm->from_dropset = thedropset;
3965 96 items.add(itm);
3966 96 }
3967 285 }
3968
3969 285 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
3970
3971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
285 if(get_qr(qr_MORESOUNDS))
3972 {
3973
5/6
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 153 times.
✓ Branch 5 taken 34 times.
285 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3974 {
3975
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if (combobuf[cid].usrflags&cflag3)
3976 {
3977 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3978 }
3979 34 }
3980 else
3981 {
3982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 251 times.
251 if (combobuf[cid].usrflags&cflag3)
3983 {
3984 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3985 }
3986 251 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
3987 }
3988 285 }
3989
3990 285 spawn_decoration_xy(combobuf[cid], fx, fy);
3991 4023900 }
3992
3993 1866950 void HeroClass::check_slash_block(int32_t bx, int32_t by)
3994 {
3995 //keep things inside the screen boundaries
3996 1866950 bx=vbound(bx, 0, 255);
3997 1866950 by=vbound(by, 0, 176);
3998 1866950 int32_t fx=vbound(bx, 0, 255);
3999 1866950 int32_t fy=vbound(by, 0, 176);
4000 //first things first
4001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1866950 times.
1866950 if(attack!=wSword)
4002 return;
4003
4004
5/6
✓ Branch 0 taken 1866806 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 1866806 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9720 times.
✓ Branch 5 taken 208924 times.
2085594 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
4005
4/4
✓ Branch 0 taken 1781514 times.
✓ Branch 1 taken 85292 times.
✓ Branch 2 taken 218644 times.
✓ Branch 3 taken 1562870 times.
1866806 || (attackclk>SWORDTAPFRAME && tapping))
4006 95156 return;
4007
4008 //find out which combo row/column the coordinates are in
4009 1771794 bx &= 0xF0;
4010 1771794 by &= 0xF0;
4011
4012 1771794 int cid = MAPCOMBO(bx,by);
4013 1771794 int cid_ff = MAPFFCOMBO(fx,fy);
4014 1771794 int current_ffcombo = getFFCAt(fx,fy);
4015 1771794 newcombo const& cmb = combobuf[cid];
4016 1771794 newcombo const& cmb_ff = combobuf[cid_ff];
4017 1771794 int type = cmb.type;
4018 1771794 int type2 = cmb_ff.type;
4019 1771794 int flag = MAPFLAG(bx,by);
4020 1771794 int flag2 = cmb.flag;
4021 1771794 int flag3 = cmb_ff.flag;
4022 1771794 int i = (bx>>4) + by;
4023
4024
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 1771601 times.
1771794 if(i > 175)
4025 193 return;
4026
4027 1771601 bool ignorescreen=false;
4028 1771601 bool ignoreffc=false;
4029
4030
2/2
✓ Branch 0 taken 1746007 times.
✓ Branch 1 taken 25594 times.
1771601 if(get_bit(screengrid, i) != 0)
4031 {
4032 25594 ignorescreen = true;
4033 25594 }
4034
2/2
✓ Branch 0 taken 1746002 times.
✓ Branch 1 taken 5 times.
1746007 else if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
4035 5 ignorescreen = true;
4036
4037
4038
4039
3/4
✓ Branch 0 taken 12071 times.
✓ Branch 1 taken 1759530 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12071 times.
1771601 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4040 {
4041 1759530 ignoreffc = true;
4042 1759530 }
4043
2/2
✓ Branch 0 taken 12052 times.
✓ Branch 1 taken 19 times.
12071 else if(cmb_ff.triggerflags[0] & combotriggerONLYGENTRIG)
4044 19 ignoreffc = true;
4045
4046
4/4
✓ Branch 0 taken 1753863 times.
✓ Branch 1 taken 17738 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 1753449 times.
3525096 if(!isCuttableType(type) &&
4047
6/6
✓ Branch 0 taken 3935 times.
✓ Branch 1 taken 1749928 times.
✓ Branch 2 taken 1753495 times.
✓ Branch 3 taken 368 times.
✓ Branch 4 taken 4688 times.
✓ Branch 5 taken 1748807 times.
1753863 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4048 {
4049 1753449 ignorescreen = true;
4050 1753449 }
4051
4052
4/4
✓ Branch 0 taken 1771582 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1771581 times.
3543183 if(!isCuttableType(type2) &&
4053
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1771581 times.
1771582 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4054 {
4055 1771581 ignoreffc = true;
4056 1771581 }
4057
4058 1771601 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4059
4060
4/4
✓ Branch 0 taken 71758 times.
✓ Branch 1 taken 1699843 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 71702 times.
1771601 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4061 1771601 byte skipsecrets = 0;
4062
4063
2/2
✓ Branch 0 taken 1764964 times.
✓ Branch 1 taken 6637 times.
1771601 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4064 {
4065
2/2
✓ Branch 0 taken 5639 times.
✓ Branch 1 taken 998 times.
6637 if (get_qr(qr_OLD_SLASHNEXT_SECRETS))
4066 {
4067 5639 skipsecrets = 0;
4068 5639 }
4069 998 else skipsecrets = 1; ;
4070 6637 }
4071
4072
6/6
✓ Branch 0 taken 16569 times.
✓ Branch 1 taken 1755032 times.
✓ Branch 2 taken 993 times.
✓ Branch 3 taken 15576 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 1037 times.
1771601 if(!ignorescreen && (!skipsecrets || !get_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS)))
4073 {
4074
6/6
✓ Branch 0 taken 1955 times.
✓ Branch 1 taken 14658 times.
✓ Branch 2 taken 1526 times.
✓ Branch 3 taken 429 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 1496 times.
16613 if((flag >= 16)&&(flag <= 31) && !skipsecrets)
4075 {
4076 1496 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4077 1496 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4078 1496 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4079 1496 }
4080
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 15113 times.
15117 else if(flag == mfARMOS_SECRET)
4081 {
4082 4 s->data[i] = s->secretcombo[sSTAIRS];
4083 4 s->cset[i] = s->secretcset[sSTAIRS];
4084 4 s->sflag[i] = s->secretflag[sSTAIRS];
4085 4 sfx(tmpscr->secretsfx);
4086 4 }
4087
4/4
✓ Branch 0 taken 393 times.
✓ Branch 1 taken 14720 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 14698 times.
15113 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4088 {
4089
4/4
✓ Branch 0 taken 1074 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 858 times.
✓ Branch 3 taken 371 times.
1273 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4090 {
4091 858 findentrance(bx,by,mfSWORD+i2,true);
4092 858 }
4093
4094 371 findentrance(bx,by,mfSTRIKE,true);
4095 371 }
4096
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 14686 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
14698 else if(((flag2 >= 16)&&(flag2 <= 31)))
4097 {
4098 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4099 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4100 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4101 }
4102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14698 times.
14698 else if(flag2 == mfARMOS_SECRET)
4103 {
4104 s->data[i] = s->secretcombo[sSTAIRS];
4105 s->cset[i] = s->secretcset[sSTAIRS];
4106 s->sflag[i] = s->secretflag[sSTAIRS];
4107 sfx(tmpscr->secretsfx);
4108 }
4109
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 14686 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14686 times.
14698 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4110 {
4111
3/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 12 times.
32 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4112 {
4113 20 findentrance(bx,by,mfSWORD+i2,true);
4114 20 }
4115
4116 12 findentrance(bx,by,mfSTRIKE,true);
4117 12 }
4118 else
4119 {
4120
2/2
✓ Branch 0 taken 5079 times.
✓ Branch 1 taken 9607 times.
14686 if(isCuttableNextType(type))
4121 {
4122 5079 s->data[i]++;
4123 5079 }
4124 else
4125 {
4126 9607 s->data[i] = s->undercombo;
4127 9607 s->cset[i] = s->undercset;
4128 9607 s->sflag[i] = 0;
4129 }
4130
4131 //pausenow=true;
4132 }
4133 16569 }
4134
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1755076 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1755076 else if(!ignorescreen && skipsecrets)
4135 {
4136 if(isCuttableNextType(type))
4137 {
4138 s->data[i]++;
4139 }
4140 else
4141 {
4142 s->data[i] = s->undercombo;
4143 s->cset[i] = s->undercset;
4144 s->sflag[i] = 0;
4145 }
4146 }
4147
4148
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1771644 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1771644 times.
1771645 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4149 {
4150
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4151 {
4152 4 findentrance(bx,by,mfSWORD+i2,true);
4153 4 }
4154
4155 1 findentrance(fx,fy,mfSTRIKE,true);
4156 1 }
4157
1/2
✓ Branch 0 taken 1771644 times.
✗ Branch 1 not taken.
1771644 else if(!ignoreffc)
4158 {
4159 if(isCuttableNextType(type2))
4160 {
4161 zc_ffc_modify(s->ffcs[current_ffcombo], 1);
4162 }
4163 else
4164 {
4165 zc_ffc_set(s->ffcs[current_ffcombo], s->undercombo);
4166 s->ffcs[current_ffcombo].cset = s->undercset;
4167 }
4168 }
4169
4170
2/2
✓ Branch 0 taken 1755076 times.
✓ Branch 1 taken 16569 times.
1771645 if(!ignorescreen)
4171 {
4172
4/4
✓ Branch 0 taken 5433 times.
✓ Branch 1 taken 11136 times.
✓ Branch 2 taken 290 times.
✓ Branch 3 taken 5143 times.
16569 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
4173
4174
8/8
✓ Branch 0 taken 16264 times.
✓ Branch 1 taken 305 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 16309 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 305 times.
✓ Branch 6 taken 45 times.
✓ Branch 7 taken 215 times.
16569 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4175 {
4176
4/8
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 260 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 260 times.
✗ Branch 7 not taken.
260 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4177 260 sfx(tmpscr->secretsfx);
4178 260 }
4179
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 15889 times.
16309 else if(isCuttableItemType(type))
4180 {
4181 15889 int32_t it = -1;
4182 15889 int32_t thedropset = -1;
4183
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 15841 times.
15889 if ( (cmb.usrflags&cflag2) ) //specific dropset or item
4184 {
4185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if ( cmb.usrflags&cflag11 )
4186 {
4187 it = cmb.attribytes[1];
4188 }
4189 else
4190 {
4191 48 it = select_dropitem(cmb.attribytes[1]);
4192 48 thedropset = cmb.attribytes[1];
4193 }
4194 48 }
4195 else
4196 {
4197 15841 it = select_dropitem(12);
4198 15841 thedropset = 12;
4199 }
4200
4201
2/2
✓ Branch 0 taken 11114 times.
✓ Branch 1 taken 4775 times.
15889 if(it!=-1)
4202 {
4203
4/8
✓ Branch 0 taken 4775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4775 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4775 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4775 times.
✗ Branch 7 not taken.
4775 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4204 4775 itm->from_dropset = thedropset;
4205 4775 items.add(itm);
4206 4775 }
4207 15889 }
4208
4209 16569 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4210
4211
2/2
✓ Branch 0 taken 8270 times.
✓ Branch 1 taken 8299 times.
16569 if(get_qr(qr_MORESOUNDS))
4212 {
4213
6/6
✓ Branch 0 taken 6765 times.
✓ Branch 1 taken 1534 times.
✓ Branch 2 taken 4720 times.
✓ Branch 3 taken 2045 times.
✓ Branch 4 taken 4095 times.
✓ Branch 5 taken 625 times.
8299 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4214 {
4215
2/2
✓ Branch 0 taken 581 times.
✓ Branch 1 taken 44 times.
625 if (cmb.usrflags&cflag3)
4216 {
4217 44 sfx(cmb.attribytes[2],int32_t(bx));
4218 44 }
4219 625 }
4220 else
4221 {
4222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7674 times.
7674 if (cmb.usrflags&cflag3)
4223 {
4224 sfx(cmb.attribytes[2],int32_t(bx));
4225 }
4226 7674 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4227 }
4228 8299 }
4229
4230 16569 spawn_decoration_xy(cmb, fx, fy);
4231 16569 }
4232
4233
2/2
✓ Branch 0 taken 1771644 times.
✓ Branch 1 taken 1 times.
1771645 if(!ignoreffc)
4234 {
4235
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!isTouchyType(type2) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4236
4237
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(isCuttableItemType(type2))
4238 {
4239 int32_t it=-1;
4240 int32_t thedropset=-1;
4241 if ( (cmb_ff.usrflags&cflag2) )
4242 {
4243 if(cmb_ff.usrflags&cflag11)
4244 it = cmb_ff.attribytes[1];
4245 else
4246 {
4247 it = select_dropitem(cmb_ff.attribytes[1]);
4248 thedropset = cmb_ff.attribytes[1];
4249 }
4250 }
4251 else
4252 {
4253 if(get_qr(qr_HARDCODED_FFC_BUSH_DROPS))
4254 {
4255 int32_t r=zc_oldrand()%100;
4256
4257 if(r<15)
4258 it=iHeart; // 15%
4259 else if(r<35)
4260 it=iRupy; // 20%
4261 }
4262 else
4263 {
4264 it = select_dropitem(12);
4265 thedropset = 12;
4266 }
4267 }
4268
4269 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4270 {
4271 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4272 itm->from_dropset = thedropset;
4273 items.add(itm);
4274 }
4275 }
4276
4277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(get_qr(qr_MORESOUNDS))
4278 {
4279
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4280 {
4281
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (cmb_ff.usrflags&cflag3)
4282 {
4283 sfx(cmb_ff.attribytes[2],int32_t(bx));
4284 }
4285 1 }
4286 else
4287 {
4288 if (cmb_ff.usrflags&cflag3)
4289 {
4290 sfx(cmb_ff.attribytes[2],int32_t(bx));
4291 }
4292 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4293 }
4294 1 }
4295
4296 1 spawn_decoration_xy(cmb_ff, fx, fy);
4297 1 }
4298 1866994 }
4299
4300 25051372 void HeroClass::check_wpn_triggers(int32_t bx, int32_t by, weapon *w)
4301 {
4302 /*
4303 int32_t par_item = w->parentitem;
4304 al_trace("check_wpn_triggers(weapon *w): par_item is: %d\n", par_item);
4305 int32_t usewpn = -1;
4306 if ( par_item > -1 )
4307 {
4308 usewpn = itemsbuf[par_item].useweapon;
4309 }
4310 else if ( par_item == -1 && w->ScriptGenerated )
4311 {
4312 usewpn = w->useweapon;
4313 }
4314 al_trace("check_wpn_triggers(weapon *w): usewpn is: %d\n", usewpn);
4315
4316 */
4317 25051372 bx=vbound(bx, 0, 255);
4318 25051372 by=vbound(by, 0, 176);
4319 25051372 int32_t cid = MAPCOMBO(bx,by);
4320
4/30
✓ Branch 0 taken 3120 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 201384 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 24842204 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 4664 times.
✗ Branch 29 not taken.
25051372 switch(w->useweapon)
4321 {
4322 case wArrow:
4323 3120 findentrance(bx,by,mfARROW,true);
4324 3120 findentrance(bx,by,mfSARROW,true);
4325 3120 findentrance(bx,by,mfGARROW,true);
4326 3120 break;
4327 case wBeam:
4328 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4329 break;
4330 case wHookshot:
4331 findentrance(bx,by,mfHOOKSHOT,true);
4332 break;
4333 case wBrang:
4334 for(int32_t i = 0; i <3; i++) findentrance(bx,by,mfBRANG+i,true);
4335 break;
4336 case wMagic:
4337 findentrance(bx,by,mfWANDMAGIC,true);
4338 break;
4339 case wRefMagic:
4340 findentrance(bx,by,mfWANDMAGIC,true);
4341 break;
4342 case wRefBeam:
4343 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4344 break;
4345 //reflected magic needs to happen in mirrors:
4346 //
4347 //findentrance(bx,by,mfREFMAGIC,true)
4348 case wRefFireball:
4349 findentrance(bx,by,mfREFFIREBALL,true);
4350 break;
4351 case wBomb:
4352 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfBOMB,true);
4353 break;
4354
4355 case wSBomb:
4356 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfSBOMB,true);
4357 break;
4358
4359 case wFire:
4360 201384 findentrance(bx,by,mfANYFIRE,true);
4361 201384 findentrance(bx,by,mfSTRONGFIRE,true);
4362 201384 findentrance(bx,by,mfMAGICFIRE,true);
4363 /* if we want the weapon to die
4364 if (findentrance(bx,by,mfANYFIRE,true) ) dead = 1;
4365 if (findentrance(bx,by,mfSTRONGFIRE,true) ) dead = 1;
4366 if (findentrance(bx,by,mfMAGICFIRE,true)) dead = 1;
4367 */
4368 201384 break;
4369
4370 case wScript1:
4371 break;
4372 case wScript2:
4373 break;
4374 case wScript3:
4375 break;
4376 case wScript4:
4377 break;
4378 case wScript5:
4379 break;
4380 case wScript6:
4381 break;
4382 case wScript7:
4383 break;
4384 case wScript8:
4385 break;
4386 case wScript9:
4387 break;
4388 case wScript10:
4389 break;
4390 case wIce:
4391 break;
4392 case wCByrna:
4393 break;
4394 case wWhistle:
4395 break;
4396 case wSSparkle:
4397 case wFSparkle:
4398 break;
4399 case wWind:
4400 break;
4401 case wBait:
4402 break;
4403 case wFlame:
4404 case wThrown:
4405 case wBombos:
4406 case wEther:
4407 case wQuake:
4408 case wSwordLA:
4409 case wSword180:
4410 case wStomp:
4411 break;
4412 case wSword:
4413 case wWand:
4414 //case wCandle:
4415 case wHSHandle:
4416 case wLitBomb:
4417 case wLitSBomb:
4418 4664 break;
4419 24842204 default: break;
4420
4421 }
4422 25051372 }
4423
4424 50102744 void HeroClass::check_slash_block_layer2(int32_t bx, int32_t by, weapon *w, int32_t layer)
4425 {
4426
4427
2/2
✓ Branch 0 taken 1937866 times.
✓ Branch 1 taken 48164878 times.
50102744 if(!(get_qr(qr_BUSHESONLAYERS1AND2)))
4428 {
4429 //zprint("bit off\n");
4430 48164878 return;
4431 }
4432 //keep things inside the screen boundaries
4433 1937866 bx=vbound(bx, 0, 255);
4434 1937866 by=vbound(by, 0, 176);
4435 1937866 int32_t fx=vbound(bx, 0, 255);
4436 1937866 int32_t fy=vbound(by, 0, 176);
4437 //first things first
4438
2/2
✓ Branch 0 taken 1931034 times.
✓ Branch 1 taken 6832 times.
1937866 if(w->useweapon != wSword)
4439 1931034 return;
4440
4441 //find out which combo row/column the coordinates are in
4442 6832 bx &= 0xF0;
4443 6832 by &= 0xF0;
4444
4445
4446 6832 int32_t flag = MAPFLAGL(layer,bx,by);
4447 6832 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
4448 6832 int32_t cid = MAPCOMBOL(layer,bx,by);
4449 6832 int32_t type = combobuf[cid].type;
4450
1/2
✓ Branch 0 taken 6832 times.
✗ Branch 1 not taken.
6832 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4451 type = cNONE;
4452 //zprint("cid is: %d\n", cid);
4453 //zprint("type is: %d\n", type);
4454 6832 int32_t i = (bx>>4) + by;
4455
4456
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 6448 times.
6832 if(i > 175)
4457 384 return;
4458
4459
4/4
✓ Branch 0 taken 6436 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 6430 times.
✓ Branch 3 taken 6 times.
6448 if((get_bit(w->wscreengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
4460 {
4461 6442 return;
4462 //ignorescreen = true;
4463 //zprint("ignoring\n");
4464 }
4465
4466
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4467
4468 {
4469
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid_layer[layer-1],i,1);
4470
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(isCuttableNextType(type) || isCuttableNextType(type))
4471 {
4472 6 FFCore.tempScreens[layer]->data[i]++;
4473 6 }
4474 else
4475 {
4476 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
4477 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
4478 FFCore.tempScreens[layer]->sflag[i] = 0;
4479 }
4480
2/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4481 {
4482 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4483 sfx(tmpscr->secretsfx);
4484 }
4485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(isCuttableItemType(type))
4486 {
4487 6 int32_t it = -1;
4488 6 int32_t thedropset = -1;
4489
4490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( (combobuf[cid].usrflags&cflag2) )
4491 {
4492 if(combobuf[cid].usrflags&cflag11)
4493 it = combobuf[cid].attribytes[1];
4494 else
4495 {
4496 it = select_dropitem(combobuf[cid].attribytes[1]);
4497 thedropset = combobuf[cid].attribytes[1];
4498 }
4499 }
4500 else
4501 {
4502 6 it = select_dropitem(12);
4503 6 thedropset = 12;
4504 }
4505
4506
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if(it!=-1)
4507 {
4508
4/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
2 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4509 2 itm->from_dropset = thedropset;
4510 2 items.add(itm);
4511 2 }
4512 6 }
4513
4514 6 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
4515
4516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(get_qr(qr_MORESOUNDS))
4517 {
4518
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4519 {
4520 if (combobuf[cid].usrflags&cflag3)
4521 {
4522 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4523 }
4524 }
4525 else
4526 {
4527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (combobuf[cid].usrflags&cflag3)
4528 {
4529 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4530 }
4531 6 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4532 }
4533 6 }
4534
4535
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4536
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(decotype > 3) decotype = 0;
4537
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4538
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 switch(decotype)
4539 {
4540 case -2: break; //nothing
4541 case -1:
4542 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
4543 break;
4544
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4545 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4546 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4547 }
4548
4549 }
4550
4551 50102744 }
4552
4553 25051482 void HeroClass::check_slash_block2(int32_t bx, int32_t by, weapon *w)
4554 {
4555 /*
4556 int32_t par_item = w->parentitem;
4557 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4558 int32_t usewpn = -1;
4559 if ( par_item > -1 )
4560 {
4561 usewpn = itemsbuf[par_item].useweapon;
4562 }
4563 else if ( par_item == -1 && w->ScriptGenerated )
4564 {
4565 usewpn = w->useweapon;
4566 }
4567 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4568 */
4569
4570
4571 //keep things inside the screen boundaries
4572 25051482 bx=vbound(bx, 0, 255);
4573 25051482 by=vbound(by, 0, 176);
4574 25051482 int32_t fx=vbound(bx, 0, 255);
4575 25051482 int32_t fy=vbound(by, 0, 176);
4576 25051482 int32_t cid = MAPCOMBO(bx,by);
4577
4578 //find out which combo row/column the coordinates are in
4579 25051482 bx &= 0xF0;
4580 25051482 by &= 0xF0;
4581
4582 25051482 int32_t type = COMBOTYPE(bx,by);
4583 25051482 int32_t type2 = FFCOMBOTYPE(fx,fy);
4584 25051482 int32_t flag = MAPFLAG(bx,by);
4585 25051482 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4586 25051482 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4587
2/2
✓ Branch 0 taken 25051268 times.
✓ Branch 1 taken 214 times.
25051482 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4588 214 type = cNONE;
4589 25051482 byte dontignore = 0;
4590 25051482 byte dontignoreffc = 0;
4591
4592
4/4
✓ Branch 0 taken 428054 times.
✓ Branch 1 taken 24623428 times.
✓ Branch 2 taken 427456 times.
✓ Branch 3 taken 598 times.
25051482 if (isCuttableType(type) && MatchComboTrigger(w, combobuf.data(), cid))
4593 {
4594 598 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4595 598 dontignore = 1;
4596 598 }
4597
4598 /*to-do, ffcs
4599 if (isCuttableType(type2) && MatchComboTrigger(w, combobuf, cid))
4600 {
4601 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4602 dontignoreffc = 1;
4603 }*/
4604
4/4
✓ Branch 0 taken 25046708 times.
✓ Branch 1 taken 4774 times.
✓ Branch 2 taken 25046110 times.
✓ Branch 3 taken 598 times.
25051482 if(w->useweapon != wSword && !dontignore) return;
4605
4606
4607 5372 int32_t i = (bx>>4) + by;
4608
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 5351 times.
5372 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4609
4610
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 5159 times.
5351 if(i > 175)
4611 192 return;
4612
4613 5159 bool ignorescreen=false;
4614 5159 bool ignoreffc=false;
4615
4616
1/2
✓ Branch 0 taken 5159 times.
✗ Branch 1 not taken.
5159 if(get_bit(w->wscreengrid, i) != 0)
4617 {
4618 ignorescreen = true; dontignore = 0;
4619 }
4620
4621 5159 int32_t current_ffcombo = getFFCAt(fx,fy);
4622
4623
3/4
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 4893 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 266 times.
5159 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4624 {
4625 4893 ignoreffc = true;
4626 4893 }
4627
1/2
✓ Branch 0 taken 266 times.
✗ Branch 1 not taken.
266 else if(combobuf[tmpscr->ffcs[current_ffcombo].data].triggerflags[0] & combotriggerONLYGENTRIG)
4628 type2 = cNONE;
4629
3/4
✓ Branch 0 taken 4439 times.
✓ Branch 1 taken 720 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4439 times.
9598 if(!isCuttableType(type) &&
4630
5/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 4339 times.
✓ Branch 2 taken 4439 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 718 times.
✓ Branch 5 taken 3721 times.
4439 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4631 {
4632 4439 ignorescreen = true;
4633 4439 }
4634
4635
3/4
✓ Branch 0 taken 5049 times.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5049 times.
10208 if(!isCuttableType(type2) &&
4636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5049 times.
5049 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4637 {
4638 5049 ignoreffc = true;
4639 5049 }
4640
4641 5159 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4642
4643
4/4
✓ Branch 0 taken 4659 times.
✓ Branch 1 taken 316 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 4426 times.
5159 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4644 4975 byte skipsecrets = 0;
4645
2/2
✓ Branch 0 taken 4438 times.
✓ Branch 1 taken 501 times.
4975 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4646 {
4647
2/2
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 3 times.
501 if (get_qr(qr_OLD_SLASHNEXT_SECRETS))
4648 {
4649 498 skipsecrets = 0;
4650 498 }
4651 3 else skipsecrets = 1;
4652 501 }
4653
6/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4936 times.
✓ Branch 2 taken 4439 times.
✓ Branch 3 taken 4436 times.
✓ Branch 4 taken 4439 times.
✓ Branch 5 taken 4933 times.
4939 if((!skipsecrets || !get_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS)) && (!ignorescreen || dontignore))
4654 {
4655
3/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 608 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9372 if((flag >= 16)&&(flag <= 31)&&!skipsecrets)
4656 {
4657 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4658 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4659 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4660 }
4661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 else if(flag == mfARMOS_SECRET)
4662 {
4663 s->data[i] = s->secretcombo[sSTAIRS];
4664 s->cset[i] = s->secretcset[sSTAIRS];
4665 s->sflag[i] = s->secretflag[sSTAIRS];
4666 sfx(tmpscr->secretsfx);
4667 }
4668
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
610 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4669 {
4670 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4671 {
4672 findentrance(bx,by,mfSWORD+i2,true);
4673 }
4674
4675 findentrance(bx,by,mfSTRIKE,true);
4676 }
4677
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
610 else if(((flag2 >= 16)&&(flag2 <= 31)))
4678 {
4679 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4680 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4681 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4682 }
4683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 else if(flag2 == mfARMOS_SECRET)
4684 {
4685 s->data[i] = s->secretcombo[sSTAIRS];
4686 s->cset[i] = s->secretcset[sSTAIRS];
4687 s->sflag[i] = s->secretflag[sSTAIRS];
4688 sfx(tmpscr->secretsfx);
4689 }
4690
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
610 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4691 {
4692 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4693 {
4694 findentrance(bx,by,mfSWORD+i2,true);
4695 }
4696
4697 findentrance(bx,by,mfSTRIKE,true);
4698 }
4699 else
4700 {
4701
2/2
✓ Branch 0 taken 501 times.
✓ Branch 1 taken 109 times.
610 if(isCuttableNextType(type))
4702 {
4703 501 s->data[i]++;
4704 501 }
4705 else
4706 {
4707 109 s->data[i] = s->undercombo;
4708 109 s->cset[i] = s->undercset;
4709 109 s->sflag[i] = 0;
4710 }
4711
4712 //pausenow=true;
4713 }
4714 610 }
4715
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4439 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4439 else if(skipsecrets && (!ignorescreen || dontignore))
4716 {
4717 if(isCuttableNextType(type))
4718 {
4719 s->data[i]++;
4720 }
4721 else
4722 {
4723 s->data[i] = s->undercombo;
4724 s->cset[i] = s->undercset;
4725 s->sflag[i] = 0;
4726 }
4727 }
4728
4729
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5049 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5049 times.
5049 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4730 {
4731 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4732 {
4733 findentrance(bx,by,mfSWORD+i2,true);
4734 }
4735
4736 findentrance(fx,fy,mfSTRIKE,true);
4737 }
4738
1/2
✓ Branch 0 taken 5049 times.
✗ Branch 1 not taken.
5049 else if(!ignoreffc)
4739 {
4740 if(isCuttableNextType(type2))
4741 {
4742 zc_ffc_modify(s->ffcs[current_ffcombo], 1);
4743 }
4744 else
4745 {
4746 zc_ffc_set(s->ffcs[current_ffcombo], s->undercombo);
4747 s->ffcs[current_ffcombo].cset = s->undercset;
4748 }
4749 }
4750
4751
3/4
✓ Branch 0 taken 4439 times.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4439 times.
5049 if(!ignorescreen || dontignore)
4752 {
4753
3/4
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 425 times.
610 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid,i,1);
4754
4755
2/8
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
610 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4756 {
4757 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4758 sfx(tmpscr->secretsfx);
4759 }
4760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 else if(isCuttableItemType(type))
4761 {
4762 610 int32_t it = -1;
4763 610 int32_t thedropset = -1;
4764
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 601 times.
610 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4765 {
4766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if ( combobuf[cid].usrflags&cflag11 )
4767 {
4768 it = combobuf[cid].attribytes[1];
4769 }
4770 else
4771 {
4772 9 it = select_dropitem(combobuf[cid].attribytes[1]);
4773 9 thedropset = combobuf[cid].attribytes[1];
4774 }
4775 9 }
4776 else
4777 {
4778 601 it = select_dropitem(12);
4779 601 thedropset = 12;
4780 }
4781
4782
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 198 times.
610 if(it!=-1)
4783 {
4784
4/8
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 198 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 198 times.
✗ Branch 7 not taken.
198 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4785 198 itm->from_dropset = thedropset;
4786 198 items.add(itm);
4787 198 }
4788 610 }
4789
4790
4791 610 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4792
4793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(get_qr(qr_MORESOUNDS))
4794 {
4795
5/6
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 179 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 100 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
610 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4796 {
4797 if (combobuf[cid].usrflags&cflag3)
4798 {
4799 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4800 }
4801 }
4802 else
4803 {
4804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if (combobuf[cid].usrflags&cflag3)
4805 {
4806 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4807 }
4808 610 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4809 }
4810 610 }
4811
4812
3/4
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 598 times.
✗ Branch 3 not taken.
610 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4813
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(decotype > 3) decotype = 0;
4814
6/8
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
610 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4815
3/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 501 times.
✓ Branch 4 taken 100 times.
✓ Branch 5 taken 9 times.
610 switch(decotype)
4816 {
4817 case -2: break; //nothing
4818 case -1:
4819 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
4820 break;
4821
3/6
✓ Branch 0 taken 501 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 501 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 501 times.
✗ Branch 5 not taken.
501 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4822
3/6
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
100 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4823
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4824 }
4825 610 }
4826
4827
1/2
✓ Branch 0 taken 5049 times.
✗ Branch 1 not taken.
5049 if(!ignoreffc)
4828 {
4829 if(!isTouchyType(type2) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4830
4831 if(isCuttableItemType(type2))
4832 {
4833 int32_t it=-1;
4834 int32_t thedropset=-1;
4835 if ( (combobuf[cid].usrflags&cflag2) )
4836 {
4837 if(combobuf[cid].usrflags&cflag11)
4838 it = combobuf[cid].attribytes[1];
4839 else
4840 {
4841 it = select_dropitem(combobuf[cid].attribytes[1]);
4842 thedropset = combobuf[cid].attribytes[1];
4843 }
4844 }
4845 else
4846 {
4847 int32_t r=zc_oldrand()%100;
4848
4849 if(r<15)
4850 {
4851 it=iHeart; // 15%
4852 }
4853 else if(r<35)
4854 {
4855 it=iRupy; // 20%
4856 }
4857 }
4858
4859 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4860 {
4861 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4862 itm->from_dropset = thedropset;
4863 items.add(itm);
4864 }
4865 }
4866
4867 if(get_qr(qr_MORESOUNDS))
4868 {
4869 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4870 {
4871 if (combobuf[cid].usrflags&cflag3)
4872 {
4873 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4874 }
4875 }
4876 else
4877 {
4878 if (combobuf[cid].usrflags&cflag3)
4879 {
4880 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4881 }
4882 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4883 }
4884 }
4885
4886 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4887 if(decotype > 3) decotype = 0;
4888 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4889 switch(decotype)
4890 {
4891 case -2: break; //nothing
4892 case -1:
4893 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
4894 break;
4895 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4896 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4897 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4898 }
4899 }
4900 25051372 }
4901
4902 25051372 void HeroClass::check_wand_block2(int32_t bx, int32_t by, weapon *w)
4903 {
4904 /*
4905 int32_t par_item = w->parentitem;
4906 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
4907 int32_t usewpn = -1;
4908 if ( par_item > -1 )
4909 {
4910 usewpn = itemsbuf[par_item].useweapon;
4911 }
4912 else if ( par_item == -1 && w->ScriptGenerated )
4913 {
4914 usewpn = w->useweapon;
4915 }
4916 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
4917 */
4918
4919 25051372 byte dontignore = 0;
4920 25051372 byte dontignoreffc = 0;
4921
4922
4923
4924
4925
4926 //keep things inside the screen boundaries
4927 25051372 bx=vbound(bx, 0, 255);
4928 25051372 by=vbound(by, 0, 176);
4929 25051372 int32_t fx=vbound(bx, 0, 255);
4930 25051372 int32_t fy=vbound(by, 0, 176);
4931 25051372 int32_t cid = MAPCOMBO(bx,by);
4932
4933 //Z_scripterrlog("check_wand_block2 MatchComboTrigger() returned: %d\n", );
4934
3/4
✓ Branch 0 taken 25051372 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2588 times.
✓ Branch 3 taken 25048784 times.
25051372 if(w->useweapon != wWand && !MatchComboTrigger (w, combobuf.data(), cid)) return;
4935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2588 times.
2588 if ( MatchComboTrigger (w, combobuf.data(), cid) ) dontignore = 1;
4936
4937 //first things first
4938
2/4
✓ Branch 0 taken 2588 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2588 times.
2588 if(z>8||fakez>8) return;
4939
4940 //find out which combo row/column the coordinates are in
4941 2588 bx &= 0xF0;
4942 2588 by &= 0xF0;
4943
4944 2588 int32_t flag = MAPFLAG(bx,by);
4945 2588 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4946 2588 int32_t flag3=0;
4947 2588 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
4948 2588 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
4949 2588 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
4950 2588 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
4951
4952
4/8
✓ Branch 0 taken 2588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2588 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2588 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2588 times.
2588 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
4953 flag3=mfWAND;
4954
4955
4/8
✓ Branch 0 taken 2588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2588 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2588 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2588 times.
2588 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
4956 flag3=mfSTRIKE;
4957
4958 2588 int32_t i = (bx>>4) + by;
4959
4960
6/12
✓ Branch 0 taken 2588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2588 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2588 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2588 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2588 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2588 times.
2588 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
4961 2588 return;
4962
4963 if(i > 175)
4964 return;
4965
4966 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4967
4968 //findentrance(bx,by,mfWAND,true);
4969 //findentrance(bx,by,mfSTRIKE,true);
4970 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
4971 {
4972 if(flag3==mfWAND||flag3==mfSTRIKE)
4973 {
4974 findentrance(fx,fy,mfWAND,true);
4975 findentrance(fx,fy,mfSTRIKE,true);
4976 }
4977 }
4978
4979 if(dontignore) { findentrance(bx,by,mfWAND,true); }
4980
4981 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4982 25051372 }
4983
4984 void HeroClass::check_slash_block(weapon *w)
4985 {
4986 //first things
4987
4988 int32_t par_item = w->parentitem;
4989 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4990 int32_t usewpn = -1;
4991 if ( par_item > -1 )
4992 {
4993 usewpn = itemsbuf[par_item].useweapon;
4994 }
4995 else if ( par_item == -1 && w->ScriptGenerated )
4996 {
4997 usewpn = w->useweapon;
4998 }
4999 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
5000 if(usewpn != wSword) return;
5001
5002
5003 int32_t bx = 0, by = 0;
5004 bx = ((int32_t)w->x) + (((int32_t)w->hit_width)/2);
5005 by = ((int32_t)w->y) + (((int32_t)w->hit_height)/2);
5006 al_trace("check_slash_block(weapon *w): bx is: %d\n", bx);
5007 al_trace("check_slash_block(weapon *w): by is: %d\n", by);
5008 //keep things inside the screen boundaries
5009 bx=vbound(bx, 0, 255);
5010 by=vbound(by, 0, 176);
5011 int32_t fx=vbound(bx, 0, 255);
5012 int32_t fy=vbound(by, 0, 176);
5013
5014 int32_t cid = MAPCOMBO(bx,by);
5015
5016 //find out which combo row/column the coordinates are in
5017 bx &= 0xF0;
5018 by &= 0xF0;
5019
5020 int32_t type = COMBOTYPE(bx,by);
5021 int32_t type2 = FFCOMBOTYPE(fx,fy);
5022 int32_t flag = MAPFLAG(bx,by);
5023 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5024 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5025 int32_t i = (bx>>4) + by;
5026
5027 if(i > 175)
5028 {
5029 al_trace("check_slash_block(weapon *w): %s\n", "i > 175");
5030 return;
5031 }
5032
5033 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
5034 type = cNONE;
5035 bool ignorescreen=false;
5036 bool ignoreffc=false;
5037
5038 if(get_bit(screengrid, i) != 0)
5039 {
5040 ignorescreen = true;
5041 }
5042
5043 int32_t current_ffcombo = getFFCAt(fx,fy);
5044
5045 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5046 {
5047 ignoreffc = true;
5048 }
5049 else if(combobuf[tmpscr->ffcs[current_ffcombo].data].triggerflags[0] & combotriggerONLYGENTRIG)
5050 type2 = cNONE;
5051 if(!isCuttableType(type) &&
5052 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
5053 {
5054 ignorescreen = true;
5055 }
5056
5057 if(!isCuttableType(type2) &&
5058 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
5059 {
5060 ignoreffc = true;
5061 }
5062
5063 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5064
5065 int32_t sworditem = (par_item >-1 ? itemsbuf[par_item].fam_type : current_item(itype_sword)); //Get the level of the item, else the highest sword level in inventory.
5066
5067 if(!ignorescreen)
5068 {
5069 if((flag >= 16)&&(flag <= 31))
5070 {
5071 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5072 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5073 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5074 }
5075 else if(flag == mfARMOS_SECRET)
5076 {
5077 s->data[i] = s->secretcombo[sSTAIRS];
5078 s->cset[i] = s->secretcset[sSTAIRS];
5079 s->sflag[i] = s->secretflag[sSTAIRS];
5080 sfx(tmpscr->secretsfx);
5081 }
5082 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
5083 {
5084 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5085 {
5086 findentrance(bx,by,mfSWORD+i2,true);
5087 }
5088
5089 findentrance(bx,by,mfSTRIKE,true);
5090 }
5091 else if(((flag2 >= 16)&&(flag2 <= 31)))
5092 {
5093 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5094 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5095 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5096 }
5097 else if(flag2 == mfARMOS_SECRET)
5098 {
5099 s->data[i] = s->secretcombo[sSTAIRS];
5100 s->cset[i] = s->secretcset[sSTAIRS];
5101 s->sflag[i] = s->secretflag[sSTAIRS];
5102 sfx(tmpscr->secretsfx);
5103 }
5104 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
5105 {
5106 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5107 {
5108 findentrance(bx,by,mfSWORD+i2,true);
5109 }
5110
5111 findentrance(bx,by,mfSTRIKE,true);
5112 }
5113 else
5114 {
5115 if(isCuttableNextType(type))
5116 {
5117 s->data[i]++;
5118 }
5119 else
5120 {
5121 s->data[i] = s->undercombo;
5122 s->cset[i] = s->undercset;
5123 s->sflag[i] = 0;
5124 }
5125
5126 //pausenow=true;
5127 }
5128 }
5129
5130 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
5131 {
5132 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5133 {
5134 findentrance(bx,by,mfSWORD+i2,true);
5135 }
5136
5137 findentrance(fx,fy,mfSTRIKE,true);
5138 }
5139 else if(!ignoreffc)
5140 {
5141 if(isCuttableNextType(type2))
5142 {
5143 zc_ffc_modify(s->ffcs[current_ffcombo], 1);
5144 }
5145 else
5146 {
5147 zc_ffc_set(s->ffcs[current_ffcombo], s->undercombo);
5148 s->ffcs[current_ffcombo].cset = s->undercset;
5149 }
5150 }
5151
5152 if(!ignorescreen)
5153 {
5154 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
5155
5156 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5157 {
5158 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5159 sfx(tmpscr->secretsfx);
5160 }
5161 else if(isCuttableItemType(type))
5162 {
5163 int32_t it = -1;
5164 int32_t thedropset = -1;
5165 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
5166 {
5167 if ( combobuf[cid].usrflags&cflag11 )
5168 {
5169 it = combobuf[cid].attribytes[1];
5170 }
5171 else
5172 {
5173 it = select_dropitem(combobuf[cid].attribytes[1]);
5174 thedropset = combobuf[cid].attribytes[1];
5175 }
5176 }
5177 else
5178 {
5179 it = select_dropitem(12);
5180 thedropset = 12;
5181 }
5182
5183 if(it!=-1)
5184 {
5185 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5186 itm->from_dropset = thedropset;
5187 items.add(itm);
5188 }
5189 }
5190
5191 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5192
5193 if(get_qr(qr_MORESOUNDS))
5194 {
5195 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
5196 {
5197 if (combobuf[cid].usrflags&cflag3)
5198 {
5199 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5200 }
5201 }
5202 else
5203 {
5204 if (combobuf[cid].usrflags&cflag3)
5205 {
5206 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5207 }
5208 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5209 }
5210 }
5211
5212 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5213 if(decotype > 3) decotype = 0;
5214 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5215 switch(decotype)
5216 {
5217 case -2: break; //nothing
5218 case -1:
5219 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
5220 break;
5221 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5222 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5223 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5224 }
5225 }
5226
5227 if(!ignoreffc)
5228 {
5229 if(!isTouchyType(type2) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
5230
5231 if(isCuttableItemType(type2))
5232 {
5233 int32_t it=-1;
5234 int32_t thedropset = -1;
5235 if ( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) )
5236 {
5237 if(combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag11)
5238 it = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5239 else
5240 {
5241 thedropset = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5242 it = select_dropitem(thedropset);
5243 }
5244 }
5245 else
5246 {
5247 it = select_dropitem(12);
5248 thedropset = 12;
5249 }
5250
5251 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
5252 {
5253 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5254 itm->from_dropset = thedropset;
5255 items.add(itm);
5256 }
5257 }
5258
5259 if(get_qr(qr_MORESOUNDS))
5260 {
5261 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
5262 {
5263 if (combobuf[cid].usrflags&cflag3)
5264 {
5265 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5266 }
5267 }
5268 else
5269 {
5270 if (combobuf[cid].usrflags&cflag3)
5271 {
5272 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5273 }
5274 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5275 }
5276 }
5277
5278 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5279 if(decotype > 3) decotype = 0;
5280 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5281 switch(decotype)
5282 {
5283 case -2: break; //nothing
5284 case -1:
5285 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
5286 break;
5287 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5288 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5289 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5290 }
5291 }
5292 }
5293
5294 //TODO: Boomerang that cuts bushes. -L
5295 /*void HeroClass::slash_bush()
5296 {
5297
5298 }*/
5299
5300 38240 void HeroClass::check_wand_block(int32_t bx, int32_t by)
5301 {
5302 //keep things inside the screen boundaries
5303 38240 bx=vbound(bx, 0, 255);
5304 38240 by=vbound(by, 0, 176);
5305 38240 int32_t fx=vbound(bx, 0, 255);
5306 38240 int32_t fy=vbound(by, 0, 176);
5307 38240 int32_t cid = MAPCOMBO(bx,by);
5308
5309 //first things first
5310
2/4
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 38240 times.
38240 if(z>8||fakez>8) return;
5311
5312 //find out which combo row/column the coordinates are in
5313 38240 bx &= 0xF0;
5314 38240 by &= 0xF0;
5315
5316 38240 int32_t flag = MAPFLAG(bx,by);
5317 38240 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5318 38240 int32_t flag3=0;
5319 38240 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5320 38240 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5321 38240 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5322 38240 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5323
5324
4/8
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38240 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 38240 times.
38240 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5325 flag3=mfWAND;
5326
5327
4/8
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38240 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 38240 times.
38240 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5328 flag3=mfSTRIKE;
5329
5330 38240 int32_t i = (bx>>4) + by;
5331
5332
7/12
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38240 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 38239 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 38239 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 38239 times.
✗ Branch 11 not taken.
38240 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5333 38239 return;
5334
5335
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(i > 175)
5336 return;
5337
5338 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5339
5340 //findentrance(bx,by,mfWAND,true);
5341 //findentrance(bx,by,mfSTRIKE,true);
5342
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5343 {
5344 if(flag3==mfWAND||flag3==mfSTRIKE)
5345 {
5346 findentrance(fx,fy,mfWAND,true);
5347 findentrance(fx,fy,mfSTRIKE,true);
5348 }
5349 }
5350
5351 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5352 38240 }
5353
5354 5120 void HeroClass::check_pound_block(int bx, int by, weapon* w)
5355 {
5356
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5120 if(w && w->no_triggers()) return;
5357
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5120 if(w && w->id == wHammer && getHammerState() < 3)
5358 return;
5359
1/2
✓ Branch 0 taken 5120 times.
✗ Branch 1 not taken.
5120 if(get_qr(qr_POUNDLAYERS1AND2))
5360 {
5361 check_pound_block_layer(bx,by,1,w);
5362 check_pound_block_layer(bx,by,2,w);
5363 }
5364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5120 times.
5120 auto* grid = w ? w->wscreengrid : screengrid;
5365 //keep things inside the screen boundaries
5366 5120 bx=vbound(bx, 0, 255);
5367 5120 by=vbound(by, 0, 176);
5368 5120 int32_t fx=vbound(bx, 0, 255);
5369 5120 int32_t fy=vbound(by, 0, 176);
5370 5120 int32_t cid = MAPCOMBO(bx,by);
5371
5372 //first things first
5373
2/4
✓ Branch 0 taken 5120 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5120 times.
5120 if(z>8||fakez>8) return;
5374
5375 //find out which combo row/column the coordinates are in
5376 5120 bx &= 0xF0;
5377 5120 by &= 0xF0;
5378
5379 5120 int32_t type = COMBOTYPE(bx,by);
5380 5120 int32_t type2 = FFCOMBOTYPE(fx,fy);
5381 5120 int32_t flag = MAPFLAG(bx,by);
5382 5120 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5383 5120 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5384 5120 int32_t i = (bx>>4) + by;
5385
5386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5120 times.
5120 if(i > 175)
5387 return;
5388
5389 5120 bool ignorescreen=false;
5390 5120 bool ignoreffc=false;
5391 5120 bool pound=false;
5392
5393
9/10
✓ Branch 0 taken 4436 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 4426 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 4426 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4424 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 4422 times.
5120 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5394 4422 ignorescreen = true; // Affect only FFCs
5395
5396
2/2
✓ Branch 0 taken 4664 times.
✓ Branch 1 taken 456 times.
5120 if(get_bit(grid, i) != 0)
5397 456 ignorescreen = true;
5398
5399 5120 int32_t current_ffcombo = getFFCAt(fx,fy);
5400
5401
3/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 5081 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
5120 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5402 5081 ignoreffc = true;
5403
5404
3/6
✓ Branch 0 taken 5120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5120 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5120 times.
5120 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5405 5120 ignoreffc = true;
5406
5407
3/4
✓ Branch 0 taken 4593 times.
✓ Branch 1 taken 527 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4593 times.
5120 if(ignorescreen && ignoreffc) // Nothing to do.
5408 4593 return;
5409
5410 527 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5411
5412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if(!ignorescreen)
5413 {
5414
3/4
✓ Branch 0 taken 499 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 499 times.
527 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5415 {
5416 28 findentrance(bx,by,mfHAMMER,true);
5417 28 findentrance(bx,by,mfSTRIKE,true);
5418 28 }
5419
3/4
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 497 times.
499 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5420 {
5421 2 findentrance(bx,by,mfHAMMER,true);
5422 2 findentrance(bx,by,mfSTRIKE,true);
5423 2 }
5424
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 492 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
497 else if((flag >= 16)&&(flag <= 31))
5425 {
5426 5 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5427 5 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5428 5 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5429 5 }
5430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 else if(flag == mfARMOS_SECRET)
5431 {
5432 s->data[i] = s->secretcombo[sSTAIRS];
5433 s->cset[i] = s->secretcset[sSTAIRS];
5434 s->sflag[i] = s->secretflag[sSTAIRS];
5435 sfx(tmpscr->secretsfx);
5436 }
5437
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 486 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
492 else if((flag2 >= 16)&&(flag2 <= 31))
5438 {
5439 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5440 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5441 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5442 }
5443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 else if(flag2 == mfARMOS_SECRET)
5444 {
5445 s->data[i] = s->secretcombo[sSTAIRS];
5446 s->cset[i] = s->secretcset[sSTAIRS];
5447 s->sflag[i] = s->secretflag[sSTAIRS];
5448 sfx(tmpscr->secretsfx);
5449 }
5450 492 else pound = true;
5451 527 }
5452
5453
1/2
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
527 if(!ignoreffc)
5454 {
5455 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5456 {
5457 findentrance(fx,fy,mfHAMMER,true);
5458 findentrance(fx,fy,mfSTRIKE,true);
5459 }
5460 else
5461 {
5462 zc_ffc_modify(s->ffcs[current_ffcombo], 1);
5463 }
5464 }
5465
5466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if(!ignorescreen)
5467 {
5468
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 492 times.
527 if(pound)
5469 492 s->data[i]+=1;
5470
5471 527 set_bit(grid,i,1);
5472
5473
5/8
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 523 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
527 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5474 {
5475
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5476 4 sfx(tmpscr->secretsfx);
5477 4 }
5478
5479
4/4
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 311 times.
527 if(type==cPOUND && get_qr(qr_MORESOUNDS))
5480 311 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5481
5482 527 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5483 527 }
5484
5485
1/2
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
527 if(!ignoreffc)
5486 {
5487 set_bit(ffcgrid,current_ffcombo,1);
5488
5489 if(type2==cPOUND && get_qr(qr_MORESOUNDS))
5490 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5491 }
5492
5493 527 return;
5494 5120 }
5495
5496 void HeroClass::check_pound_block_layer(int bx, int by, int lyr, weapon* w)
5497 {
5498 if(lyr < 1 || lyr > 2) return; //sanity
5499 //keep things inside the screen boundaries
5500 bx=vbound(bx, 0, 255);
5501 by=vbound(by, 0, 176);
5502 int32_t cid = MAPCOMBOL(lyr,bx,by);
5503 newcombo const& scr_cmb = combobuf[cid];
5504 auto* grid = w ? w->wscreengrid_layer[lyr-1] : screengrid_layer[lyr-1];
5505
5506 //first things first
5507 if(z>8||fakez>8) return;
5508
5509 //find out which combo row/column the coordinates are in
5510 bx &= 0xF0;
5511 by &= 0xF0;
5512
5513 int32_t type = scr_cmb.type;
5514 int32_t flag = MAPFLAGL(lyr,bx,by);
5515 int32_t flag2 = scr_cmb.flag;
5516 int32_t i = (bx>>4) + by;
5517
5518 if(i > 175)
5519 return;
5520
5521 bool pound=false;
5522
5523 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5524 return;
5525
5526 if(get_bit(grid, i) != 0)
5527 return;
5528
5529 mapscr *s = FFCore.tempScreens[lyr];
5530
5531 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5532 {
5533 findentrance(bx,by,mfHAMMER,true);
5534 findentrance(bx,by,mfSTRIKE,true);
5535 }
5536 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5537 {
5538 findentrance(bx,by,mfHAMMER,true);
5539 findentrance(bx,by,mfSTRIKE,true);
5540 }
5541 else if((flag >= 16)&&(flag <= 31))
5542 {
5543 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5544 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5545 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5546 }
5547 else if(flag == mfARMOS_SECRET)
5548 {
5549 s->data[i] = s->secretcombo[sSTAIRS];
5550 s->cset[i] = s->secretcset[sSTAIRS];
5551 s->sflag[i] = s->secretflag[sSTAIRS];
5552 sfx(tmpscr->secretsfx);
5553 }
5554 else if((flag2 >= 16)&&(flag2 <= 31))
5555 {
5556 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5557 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5558 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5559 }
5560 else if(flag2 == mfARMOS_SECRET)
5561 {
5562 s->data[i] = s->secretcombo[sSTAIRS];
5563 s->cset[i] = s->secretcset[sSTAIRS];
5564 s->sflag[i] = s->secretflag[sSTAIRS];
5565 sfx(tmpscr->secretsfx);
5566 }
5567 else pound = true;
5568
5569 if(pound)
5570 s->data[i]+=1;
5571
5572 set_bit(grid,i,1);
5573
5574 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5575 {
5576 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5577 sfx(tmpscr->secretsfx);
5578 }
5579
5580 if(type==cPOUND && get_qr(qr_MORESOUNDS))
5581 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5582
5583 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5584 }
5585
5586 void HeroClass::check_wand_block(weapon *w)
5587 {
5588
5589 int32_t par_item = w->parentitem;
5590 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
5591 int32_t usewpn = -1;
5592 if ( par_item > -1 )
5593 {
5594 usewpn = itemsbuf[par_item].useweapon;
5595 }
5596 else if ( par_item == -1 && w->ScriptGenerated )
5597 {
5598 usewpn = w->useweapon;
5599 }
5600 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
5601 if(usewpn != wWand) return;
5602
5603
5604 int32_t bx = 0, by = 0;
5605 bx = ((int32_t)w->x) + (((int32_t)w->hit_width)/2);
5606 by = ((int32_t)w->y) + (((int32_t)w->hit_height)/2);
5607
5608 //keep things inside the screen boundaries
5609 bx=vbound(bx, 0, 255);
5610 by=vbound(by, 0, 176);
5611 int32_t fx=vbound(bx, 0, 255);
5612 int32_t fy=vbound(by, 0, 176);
5613 int32_t cid = MAPCOMBO(bx,by);
5614 //first things first
5615 if(z>8||fakez>8) return;
5616
5617 //find out which combo row/column the coordinates are in
5618 bx &= 0xF0;
5619 by &= 0xF0;
5620
5621 int32_t flag = MAPFLAG(bx,by);
5622 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5623 int32_t flag3=0;
5624 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5625 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5626 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5627 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5628
5629 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5630 flag3=mfWAND;
5631
5632 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5633 flag3=mfSTRIKE;
5634
5635 int32_t i = (bx>>4) + by;
5636
5637 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5638 return;
5639
5640 if(i > 175)
5641 return;
5642
5643 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5644
5645 //findentrance(bx,by,mfWAND,true);
5646 //findentrance(bx,by,mfSTRIKE,true);
5647 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5648 {
5649 if(flag3==mfWAND||flag3==mfSTRIKE)
5650 {
5651 findentrance(fx,fy,mfWAND,true);
5652 findentrance(fx,fy,mfSTRIKE,true);
5653 }
5654 }
5655
5656 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5657 }
5658
5659 //defend results should match defence types.
5660 //RETURN VALUES:
5661 // -1 iGNORE WEAPON
5662 // 0 No effects
5663 // 1 Effects, weapon is not ignored or removed
5664 11536 int32_t HeroClass::defend(weapon *w)
5665 {
5666 11536 int32_t def = conv_edef_unblockable(defence[w->id], w->unblockable);
5667
2/25
✓ Branch 0 taken 11527 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
11536 switch(def)
5668 {
5669 11527 case edNORMAL: return 1;
5670 case edHALFDAMAGE: // : IMPLEMENTED : Take half damage
5671 {
5672 w->power *= 0.5;
5673 return 1;
5674 }
5675 case edQUARTDAMAGE:
5676 {
5677 w->power *= 0.25;
5678 return 1;
5679 }
5680 case edSTUNONLY:
5681 {
5682 setStunClock(120);
5683 return 1;
5684 }
5685 case edSTUNORCHINK: // : IMPLEMENTED : If damage > 0, stun instead. Else, bounce off.
5686 {
5687 if (w->power > 0)
5688 {
5689 setStunClock(120);
5690 return 1;
5691 }
5692 else
5693 {
5694 sfx(WAV_CHINK,pan(int32_t(x)));
5695 w->dead = 0;
5696 return -1;
5697 }
5698 }
5699 case edSTUNORIGNORE: // : IMPLEMENTED : If damage > 0, stun instead. Else, ignore.
5700 {
5701 if (w->power > 0)
5702 {
5703 setStunClock(120);
5704 return 1;
5705 }
5706 else
5707 {
5708 return -1;
5709 }
5710 }
5711 case edCHINKL1: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5712 {
5713 if (w->power < 1)
5714 {
5715 sfx(WAV_CHINK,pan(int32_t(x)));
5716 w->dead = 0;
5717 return -1;
5718 }
5719 else
5720 {
5721 return 1;
5722 }
5723 }
5724 case edCHINKL2: // : IMPLEMENTED : Bounce off unless damage >= 2
5725 {
5726 if (w->power < 2)
5727 {
5728 sfx(WAV_CHINK,pan(int32_t(x)));
5729 w->dead = 0;
5730 return -1;
5731 }
5732 else
5733 {
5734 return 1;
5735 }
5736 }
5737 case edCHINKL4: //: IMPLEMENTED : Bounce off unless damage >= 4
5738 {
5739 if (w->power < 4)
5740 {
5741 sfx(WAV_CHINK,pan(int32_t(x)));
5742 w->dead = 0;
5743 return -1;
5744 }
5745 else
5746 {
5747 return 1;
5748 }
5749 }
5750 case edCHINKL6: // : IMPLEMENTED : Bounce off unless damage >= 6
5751 {
5752 if (w->power < 6)
5753 {
5754 sfx(WAV_CHINK,pan(int32_t(x)));
5755 w->dead = 0;
5756 return -1;
5757 }
5758 else
5759 {
5760 return 1;
5761 }
5762 }
5763 case edCHINKL8: // : IMPLEMENTED : Bounce off unless damage >= 8
5764 {
5765 if (w->power < 8)
5766 {
5767 sfx(WAV_CHINK,pan(int32_t(x)));
5768 w->dead = 0;
5769 return -1;
5770 }
5771 else
5772 {
5773 return 1;
5774 }
5775 }
5776 case edCHINK: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5777 {
5778 sfx(WAV_CHINK,pan(int32_t(x)));
5779 w->dead = 0;
5780 return -1;
5781 }
5782 case edIGNOREL1: // : IMPLEMENTED : Ignore unless damage > 1.
5783 {
5784 if (w->power < 1)
5785 {
5786 return -1;
5787 }
5788 else return 1;
5789 }
5790 case edIGNORE: // : IMPLEMENTED : Do Nothing
5791 {
5792 return -1;
5793 }
5794 case ed1HKO: // : IMPLEMENTED : One-hit knock-out
5795 {
5796 game->set_life(0);
5797 return 1;
5798 }
5799 case edCHINKL10: //: IMPLEMENTED : If damage is less than 10
5800 {
5801 if (w->power < 10)
5802 {
5803 sfx(WAV_CHINK,pan(int32_t(x)));
5804 w->dead = 0;
5805 return -1;
5806 }
5807 else
5808 {
5809 return 1;
5810 }
5811 }
5812 case ed2x: // : IMPLEMENTED : Double damage.
5813 {
5814 w->power *= 2;
5815 return 1;
5816 }
5817 case ed3x: // : IMPLEMENTED : Triple Damage.
5818 {
5819 w->power *= 3;
5820 return 1;
5821 }
5822 case ed4x: // : IMPLEMENTED : 4x damage.
5823 {
5824 w->power *= 4;
5825 return 1;
5826 }
5827 case edHEAL: // : IMPLEMENTED : Gain the weapon damage in HP.
5828 {
5829 //sfx(WAV_HEAL,pan(int32_t(x)));
5830 game->set_life(zc_min(game->get_life()+w->power, game->get_maxlife()));
5831 w->dead = 0;
5832 return -1;
5833 }
5834
5835 case edFREEZE: return 1; //Not IMPLEMENTED
5836
5837 case edLEVELDAMAGE: //Damage * item level
5838 {
5839 w->power *= w->family_level;
5840 return 1;
5841 }
5842 case edLEVELREDUCTION: //Damage / item level
5843 {
5844 if ( w->family_level > 0 )
5845 {
5846 w->power /= w->family_level;
5847 }
5848 else w->power = 0;
5849 return 1;
5850 }
5851
5852 //edLEVELCHINK2, //If item level is < 2: This needs a weapon variable that is set by
5853 //edLEVELCHINK3, //If item level is < 3: the item that generates it (itemdata::level stored to
5854 //edLEVELCHINK4, //If item level is < 4: weapon::level, or something similar; then a check to
5855 //edLEVELCHINK5, //If item level is < 5: read weapon::level in hit detection.
5856
5857 //edSHOCK, //buzz blob
5858
5859
5860 case edBREAKSHIELD: //destroy the player's present shield
5861 {
5862 w->power = 0;
5863 w->dead = 0;
5864 int32_t itemid = getCurrentShield();
5865 //sfx(WAV_BREAKSHIELD,pan(int32_t(x)));
5866 if(itemsbuf[itemid].flags&item_edible)
5867 game->set_item(itemid, false);
5868 //Remove Hero's shield
5869 return -1;
5870 }
5871
5872
5873
5874 9 default: return 0;
5875 }
5876 11536 }
5877 ALLEGRO_COLOR HeroClass::hitboxColor(byte opacity) const
5878 {
5879 return al_map_rgba(0,0,255,opacity);
5880 }
5881 10936 int32_t HeroClass::compareDir(int32_t other)
5882 {
5883
5/6
✓ Branch 0 taken 10919 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10919 times.
✓ Branch 4 taken 105 times.
✓ Branch 5 taken 10831 times.
10936 if(other != NORMAL_DIR(other))
5884 105 return 0; //*sigh* scripts expect dirs >=8 to NOT hit shields...
5885 10831 int32_t ret = 0;
5886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10831 times.
10831 auto d = (shield_forcedir < 0) ? dir : shield_forcedir;
5887
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2141 times.
✓ Branch 2 taken 1854 times.
✓ Branch 3 taken 3459 times.
✓ Branch 4 taken 3377 times.
10831 switch(d)
5888 {
5889 case up:
5890 {
5891
3/3
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 848 times.
✓ Branch 2 taken 784 times.
2141 switch(X_DIR(other))
5892 {
5893 case left:
5894 848 ret |= CMPDIR_RIGHT;
5895 848 break;
5896 case right:
5897 784 ret |= CMPDIR_LEFT;
5898 784 break;
5899 }
5900
3/3
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 335 times.
✓ Branch 2 taken 1551 times.
2141 switch(Y_DIR(other))
5901 {
5902 case up:
5903 335 ret |= CMPDIR_BACK;
5904 335 break;
5905 case down:
5906 1551 ret |= CMPDIR_FRONT;
5907 1551 break;
5908 }
5909 2141 break;
5910 }
5911 case down:
5912 {
5913
3/3
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 617 times.
✓ Branch 2 taken 709 times.
1854 switch(X_DIR(other))
5914 {
5915 case left:
5916 617 ret |= CMPDIR_LEFT;
5917 617 break;
5918 case right:
5919 709 ret |= CMPDIR_RIGHT;
5920 709 break;
5921 }
5922
3/3
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1262 times.
✓ Branch 2 taken 317 times.
1854 switch(Y_DIR(other))
5923 {
5924 case up:
5925 1262 ret |= CMPDIR_FRONT;
5926 1262 break;
5927 case down:
5928 317 ret |= CMPDIR_BACK;
5929 317 break;
5930 }
5931 1854 break;
5932 }
5933 case left:
5934 {
5935
3/3
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 494 times.
✓ Branch 2 taken 2768 times.
3459 switch(X_DIR(other))
5936 {
5937 case left:
5938 494 ret |= CMPDIR_BACK;
5939 494 break;
5940 case right:
5941 2768 ret |= CMPDIR_FRONT;
5942 2768 break;
5943 }
5944
3/3
✓ Branch 0 taken 1383 times.
✓ Branch 1 taken 891 times.
✓ Branch 2 taken 1185 times.
3459 switch(Y_DIR(other))
5945 {
5946 case up:
5947 891 ret |= CMPDIR_LEFT;
5948 891 break;
5949 case down:
5950 1185 ret |= CMPDIR_RIGHT;
5951 1185 break;
5952 }
5953 3459 break;
5954 }
5955 case right:
5956 {
5957
3/3
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 2705 times.
✓ Branch 2 taken 483 times.
3377 switch(X_DIR(other))
5958 {
5959 case left:
5960 2705 ret |= CMPDIR_FRONT;
5961 2705 break;
5962 case right:
5963 483 ret |= CMPDIR_BACK;
5964 483 break;
5965 }
5966
3/3
✓ Branch 0 taken 1337 times.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1208 times.
3377 switch(Y_DIR(other))
5967 {
5968 case up:
5969 832 ret |= CMPDIR_RIGHT;
5970 832 break;
5971 case down:
5972 1208 ret |= CMPDIR_LEFT;
5973 1208 break;
5974 }
5975 3377 break;
5976 }
5977 }
5978 10831 return ret;
5979 10936 }
5980
5981 10936 bool compareShield(int32_t cmpdir, itemdata const& shield)
5982 {
5983
1/2
✓ Branch 0 taken 10936 times.
✗ Branch 1 not taken.
10936 bool standard = !(shield.flags&item_flag9) || usingActiveShield();
5984
1/2
✓ Branch 0 taken 10936 times.
✗ Branch 1 not taken.
10936 if(standard) //Use standard sides, either a passive shield, or a held active shield
5985 {
5986
4/4
✓ Branch 0 taken 8286 times.
✓ Branch 1 taken 2650 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 8277 times.
10936 if((cmpdir&CMPDIR_FRONT) && (shield.flags&item_flag1))
5987 8277 return true;
5988
3/4
✓ Branch 0 taken 1629 times.
✓ Branch 1 taken 1030 times.
✓ Branch 2 taken 1629 times.
✗ Branch 3 not taken.
2659 else if((cmpdir&CMPDIR_BACK) && (shield.flags&item_flag2))
5989 return true;
5990
3/4
✓ Branch 0 taken 1029 times.
✓ Branch 1 taken 1630 times.
✓ Branch 2 taken 1029 times.
✗ Branch 3 not taken.
2659 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&item_flag3))
5991 return true;
5992
3/4
✓ Branch 0 taken 1140 times.
✓ Branch 1 taken 1519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1140 times.
2659 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&item_flag4))
5993 return true;
5994 2659 }
5995 else //Active Shield that is NOT held down
5996 {
5997 if((cmpdir&CMPDIR_FRONT) && (shield.flags&item_flag5))
5998 return true;
5999 else if((cmpdir&CMPDIR_BACK) && (shield.flags&item_flag6))
6000 return true;
6001 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&item_flag7))
6002 return true;
6003 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&item_flag8))
6004 return true;
6005 }
6006 2659 return false;
6007 10936 }
6008
6009 7259 static bool sh_check(uint fl_block, uint fl_ref, int wty, bool& reflect, bool boss, bool defret)
6010 {
6011 7259 reflect = false;
6012
10/20
✓ Branch 0 taken 3555 times.
✓ Branch 1 taken 329 times.
✓ Branch 2 taken 416 times.
✓ Branch 3 taken 988 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 510 times.
✓ Branch 6 taken 1039 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 20 times.
✓ Branch 9 taken 391 times.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
7259 switch(wty)
6013 {
6014 case ewBrang:
6015
1/2
✓ Branch 0 taken 391 times.
✗ Branch 1 not taken.
391 if(!(fl_block & sh_brang)) break;
6016
6017 391 reflect = ((fl_ref & sh_brang) != 0);
6018 391 return true;
6019 case ewArrow:
6020 case wRefArrow:
6021
1/2
✓ Branch 0 taken 329 times.
✗ Branch 1 not taken.
329 if(!(fl_block & sh_arrow)) break;
6022
6023 329 reflect = ((fl_ref & sh_arrow) != 0);
6024 329 return true;
6025
6026 case ewRock:
6027 case wRefRock:
6028
1/2
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
416 if(!(fl_block & sh_rock)) break;
6029
6030 416 reflect = ((fl_ref & sh_rock) != 0);
6031 416 return true;
6032 case ewFlame:
6033 case wRefFire:
6034
2/2
✓ Branch 0 taken 639 times.
✓ Branch 1 taken 349 times.
988 if(!(fl_block & sh_flame)) break;
6035
6036 639 reflect = ((fl_ref & sh_flame) != 0);
6037 639 return true;
6038 case ewFlame2:
6039 case wRefFire2:
6040 if(get_qr(qr_BROKEN_FLAME_ARROW_REFLECTING))
6041 return true;
6042 if(!(fl_block & sh_flame2)) break;
6043
6044 reflect = ((fl_ref & sh_flame2) != 0);
6045 return true;
6046
6047 case ewFireball2:
6048 case ewFireball:
6049 case wRefFireball:
6050 {
6051 3555 int32_t mask = (boss ? sh_fireball2 : sh_fireball);
6052
6053
2/2
✓ Branch 0 taken 3071 times.
✓ Branch 1 taken 484 times.
3555 if(!(fl_block & mask)) break;
6054
6055 3071 reflect = ((fl_ref & mask) != 0);
6056 3071 return true;
6057 }
6058
6059 case ewSword:
6060 case wRefBeam:
6061
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 91 times.
510 if(!(fl_block & sh_sword)) break;
6062
6063 419 reflect = ((fl_ref & sh_sword) != 0);
6064 419 return true;
6065
6066 case wRefMagic:
6067 case ewMagic:
6068
2/2
✓ Branch 0 taken 969 times.
✓ Branch 1 taken 70 times.
1039 if(!(fl_block & sh_magic)) break;
6069
6070 969 reflect = ((fl_ref & sh_magic) != 0);
6071 969 return true;
6072
6073 #define SCRIPT_SHBLOCK(scrfl) \
6074 if(!(fl_block & (sh_script|scrfl))) break; \
6075 reflect = ((fl_ref & (sh_script|scrfl)) != 0); \
6076 return true
6077
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 case wScript1: SCRIPT_SHBLOCK(sh_script1);
6078 case wScript2: SCRIPT_SHBLOCK(sh_script2);
6079 case wScript3: SCRIPT_SHBLOCK(sh_script3);
6080 case wScript4: SCRIPT_SHBLOCK(sh_script4);
6081 case wScript5: SCRIPT_SHBLOCK(sh_script5);
6082 case wScript6: SCRIPT_SHBLOCK(sh_script6);
6083 case wScript7: SCRIPT_SHBLOCK(sh_script7);
6084 case wScript8: SCRIPT_SHBLOCK(sh_script8);
6085 case wScript9: SCRIPT_SHBLOCK(sh_script9);
6086 case wScript10: SCRIPT_SHBLOCK(sh_script10);
6087 #undef SCRIPT_SHBLOCK
6088
6089 case ewLitBomb:
6090 case ewLitSBomb:
6091 2 return true;
6092
6093 default:
6094 20 return defret;
6095 }
6096 1003 return false;
6097 7259 }
6098
6099 bool HeroClass::check_ewpn_collide(weapon* w)
6100 {
6101 if(w->ignoreHero || w->fallclk|| w->drownclk)
6102 return false;
6103 if(!w->hit(x+7,y+7-fakez,z,2,2,1))
6104 return false;
6105
6106 int32_t stompid = current_item_id(itype_stompboots);
6107
6108 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
6109 ((z+fakez) > (w->z+(w->fakez))) ||
6110 ((isSideViewHero() && (y+16)-(w->y)<=14) && falling_oldy<y)))
6111 {
6112 itemdata const& stomp = itemsbuf[stompid];
6113 bool reflect = false; //unused, always false
6114 if(!sh_check(stomp.misc2, 0, w->id, reflect, w->type&1, true))
6115 {
6116 w->onhit(false);
6117 sfx(WAV_CHINK,pan(x.getInt()));
6118 return false;
6119 }
6120 }
6121
6122 int32_t defresult = defend(w);
6123 if ( defresult == -1 ) return false; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
6124
6125 if(w->id==ewWind)
6126 {
6127 xofs=1000;
6128 action=freeze; FFCore.setHeroAction(freeze);
6129 w->misc=999; // in enemy wind
6130 attackclk=0;
6131 return false;
6132 }
6133
6134 switch(w->id)
6135 {
6136 case ewLitBomb:
6137 case ewBomb:
6138 case ewLitSBomb:
6139 case ewSBomb:
6140 return true;
6141 }
6142
6143 int32_t itemid = getCurrentShield(false);
6144 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6145 return true;
6146 itemdata const& shield = itemsbuf[itemid];
6147 bool allow_inactive = (shield.flags & item_flag9);
6148 auto cmpdir = compareDir(w->dir);
6149 bool hitshield = compareShield(cmpdir, shield);
6150
6151 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6152 return true;
6153
6154 if(!hitshield)
6155 return true;
6156
6157 paymagiccost(itemid);
6158
6159 bool reflect = false;
6160
6161 if(!sh_check(shield.misc1, shield.misc2, w->id, reflect, w->type&1, true))
6162 return true;
6163
6164 if(reflect && (w->unblockable&WPNUNB_REFL))
6165 reflect = false;
6166 if(!reflect && (w->unblockable&WPNUNB_SHLD))
6167 return true;
6168
6169 int32_t oldid = w->id;
6170 w->onhit(false, reflect ? 2 : 1, dir);
6171
6172 sfx(shield.usesound,pan(x.getInt()));
6173 return true;
6174 }
6175
6176 12817980 int32_t HeroClass::EwpnHit()
6177 {
6178
2/2
✓ Branch 0 taken 12812555 times.
✓ Branch 1 taken 7494126 times.
20306681 for(int32_t i=0; i<Ewpns.Count(); i++)
6179 {
6180
2/2
✓ Branch 0 taken 7482590 times.
✓ Branch 1 taken 11536 times.
7494126 if(Ewpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6181 {
6182 11536 weapon *ew = (weapon*)(Ewpns.spr(i));
6183
6184
3/6
✓ Branch 0 taken 11536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11536 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11536 times.
11536 if((ew->ignoreHero)==true || ew->fallclk|| ew->drownclk)
6185 break;
6186
6187 11536 int32_t stompid = current_item_id(itype_stompboots);
6188
6189
5/10
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11530 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
11536 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
6190
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((z+fakez) > (ew->z+(ew->fakez))) ||
6191
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 ((isSideViewHero() && (y+16)-(ew->y)<=14) && falling_oldy<y)))
6192 {
6193 itemdata const& stomp = itemsbuf[stompid];
6194 bool reflect = false; //unused, always false
6195 if(!sh_check(stomp.misc2, 0, ew->id, reflect, ew->type&1, true))
6196 {
6197 ew->onhit(false);
6198 sfx(WAV_CHINK,pan(x.getInt()));
6199 continue;
6200 }
6201 }
6202
6203 11536 int32_t defresult = defend(ew);
6204
1/2
✓ Branch 0 taken 11536 times.
✗ Branch 1 not taken.
11536 if ( defresult == -1 ) return -1; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
6205
6206
2/2
✓ Branch 0 taken 11533 times.
✓ Branch 1 taken 3 times.
11536 if(ew->id==ewWind)
6207 {
6208 3 xofs=1000;
6209 3 action=freeze; FFCore.setHeroAction(freeze);
6210 3 ew->misc=999; // in enemy wind
6211 3 attackclk=0;
6212 3 return -1;
6213 }
6214
6215
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 11442 times.
11533 switch(ew->id)
6216 {
6217 case ewLitBomb:
6218 case ewBomb:
6219 case ewLitSBomb:
6220 case ewSBomb:
6221 91 return i;
6222 }
6223
6224 11442 int32_t itemid = getCurrentShield(false);
6225
4/6
✓ Branch 0 taken 10924 times.
✓ Branch 1 taken 518 times.
✓ Branch 2 taken 10924 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10924 times.
11442 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6226 518 return i;
6227 10924 itemdata const& shield = itemsbuf[itemid];
6228 10924 bool allow_inactive = (shield.flags & item_flag9);
6229 10924 auto cmpdir = compareDir(ew->dir);
6230 10924 bool hitshield = compareShield(cmpdir, shield);
6231
6232
12/20
✓ Branch 0 taken 10924 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10924 times.
✓ Branch 4 taken 8814 times.
✓ Branch 5 taken 2110 times.
✓ Branch 6 taken 8814 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8752 times.
✓ Branch 9 taken 62 times.
✓ Branch 10 taken 8752 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 8752 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 8752 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 8752 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 8752 times.
✗ Branch 19 not taken.
10924 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6233 2172 return i;
6234
6235
2/2
✓ Branch 0 taken 6765 times.
✓ Branch 1 taken 1987 times.
8752 if(!hitshield)
6236 1987 return i;
6237
6238 6765 paymagiccost(itemid);
6239
6240 6765 bool reflect = false;
6241
6242
2/2
✓ Branch 0 taken 6111 times.
✓ Branch 1 taken 654 times.
6765 if(!sh_check(shield.misc1, shield.misc2, ew->id, reflect, ew->type&1, true))
6243 654 return i;
6244
6245
3/4
✓ Branch 0 taken 1609 times.
✓ Branch 1 taken 4502 times.
✓ Branch 2 taken 1609 times.
✗ Branch 3 not taken.
6111 if(reflect && (ew->unblockable&WPNUNB_REFL))
6246 reflect = false;
6247
3/4
✓ Branch 0 taken 4502 times.
✓ Branch 1 taken 1609 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4502 times.
6111 if(!reflect && (ew->unblockable&WPNUNB_SHLD))
6248 return i;
6249
6250 6111 int32_t oldid = ew->id;
6251 6111 ew->onhit(false, reflect ? 2 : 1, dir);
6252
6253 6111 sfx(shield.usesound,pan(x.getInt()));
6254 6111 }
6255 7488701 }
6256
6257 12812555 return -1;
6258 12817980 }
6259
6260 12817990 int32_t HeroClass::LwpnHit() //only here to check magic hits
6261 {
6262
2/2
✓ Branch 0 taken 12647880 times.
✓ Branch 1 taken 4274220 times.
16922100 for(int32_t i=0; i<Lwpns.Count(); i++)
6263
2/2
✓ Branch 0 taken 4104104 times.
✓ Branch 1 taken 170116 times.
4274226 if(Lwpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6264 {
6265 170116 weapon *lw = (weapon*)(Lwpns.spr(i));
6266
6267
2/2
✓ Branch 0 taken 165522 times.
✓ Branch 1 taken 4594 times.
170116 if((lw->ignoreHero)==true)
6268 4594 break;
6269
6270
2/2
✓ Branch 0 taken 165506 times.
✓ Branch 1 taken 16 times.
165522 switch(lw->id)
6271 {
6272 case wRefFireball:
6273 case wRefMagic:
6274 case wRefBeam:
6275 case wRefRock:
6276 case wRefArrow:
6277 case wRefFire:
6278 case wRefFire2:
6279 16 break;
6280 default:
6281 165506 return -1;
6282 }
6283 16 int32_t itemid = getCurrentShield(false);
6284
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
16 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6285 4 return i;
6286 12 itemdata const& shield = itemsbuf[itemid];
6287 12 auto cmpdir = compareDir(lw->dir);
6288 12 bool hitshield = compareShield(cmpdir, shield);
6289 12 bool reflect = false;
6290
6291
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if(!hitshield)
6292 6 return i;
6293
6294 6 bool allow_inactive = (shield.flags & item_flag9);
6295
10/20
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 6 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 6 times.
✗ Branch 19 not taken.
6 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6296 return i;
6297
6298
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!sh_check(shield.misc1, shield.misc2, lw->id, reflect, lw->type&1, true))
6299 return i;
6300
6301 6 paymagiccost(itemid);
6302
6303 6 lw->onhit(false, reflect ? 2 : 1, dir);
6304 6 sfx(shield.usesound,pan(x.getInt()));
6305 6 }
6306
6307 12652474 return -1;
6308 12817990 }
6309
6310 120 bool HeroClass::try_lwpn_hit(weapon* w)
6311 {
6312 120 int32_t itemid = w->parentitem;
6313 120 int indx = Lwpns.find(w);
6314 //if ( itemdbuf[parentitem].flags&item_flags3 ) //can damage Hero
6315 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6316
7/12
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 80 times.
✓ Branch 4 taken 40 times.
✓ Branch 5 taken 40 times.
✓ Branch 6 taken 40 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 40 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
120 if((!(itemid==-1&&get_qr(qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & item_flag3)))) && scriptcoldet && !fallclk && (!superman || !get_qr(qr_FIREPROOFHERO2)))
6317 {
6318
2/10
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 40 times.
40 if(w->id==wFire && (superman ? (diagonalMovement?w->hit(x+4,y+4-fakez,z,7,7,1):w->hit(x+7,y+7-fakez,z,2,2,1)) : w->hit(this))&&
6319 (itemid < 0 || itemsbuf[itemid].family!=itype_divinefire))
6320 {
6321 std::vector<int32_t> &ev = FFCore.eventData;
6322 ev.clear();
6323 ev.push_back(lwpn_dp(indx)*10000);
6324 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6325 ev.push_back(0);
6326 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6327 ev.push_back(48*10000);
6328 ev.push_back(ZSD_LWPN*10000);
6329 ev.push_back(w->getUID());
6330 ev.push_back(ZSD_NONE*10000);
6331 ev.push_back(0);
6332
6333 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6334 int32_t dmg = ev[0]/10000;
6335 bool nullhit = ev[2] != 0;
6336
6337 if(nullhit) {ev.clear(); return true;}
6338
6339 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6340 ev[0] = ringpower(dmg)*10000;
6341
6342 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6343 dmg = ev[0]/10000;
6344 int32_t hdir = ev[1]/10000;
6345 nullhit = ev[2] != 0;
6346 bool divineprot = ev[3] != 0;
6347 int32_t iframes = ev[4] / 10000;
6348 ev.clear();
6349 if(nullhit) return true;
6350 if (Lwpns.spr(indx) != w)
6351 {
6352 auto hit = Lwpns.find(w);
6353 if (hit < 0)
6354 w = nullptr;
6355 else
6356 {
6357 w = (weapon*)Lwpns.spr(hit);
6358 indx = hit;
6359 }
6360 }
6361 if(!divineprot)
6362 {
6363 game->set_life(zc_max(game->get_life()-dmg,0));
6364 if (!get_qr(qr_BROKENHITBY) && w)
6365 {
6366 sethitHeroUID(HIT_BY_LWEAPON,(indx+1));
6367 if (get_qr(qr_BROKENHITBY))
6368 {
6369 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6370 }
6371 else
6372 {
6373
6374 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getScriptUID());
6375 }
6376 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6377 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6378 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6379 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6380 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].family);
6381 }
6382 }
6383
6384 hitdir = hdir;
6385
6386 if (action != rafting && action != freeze && action != sideswimfreeze)
6387 {
6388 if (IsSideSwim())
6389 {
6390 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6391 }
6392 else if (action == swimming || hopclk == 0xFF)
6393 {
6394 action=swimhit; FFCore.setHeroAction(swimhit);
6395 }
6396 else
6397 {
6398 action=gothit; FFCore.setHeroAction(gothit);
6399 }
6400 }
6401
6402 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6403 {
6404 spins = charging = attackclk = 0;
6405 attack=none;
6406 tapping = false;
6407 }
6408
6409 hclk=iframes;
6410 sfx(getHurtSFX(),pan(x.getInt()));
6411 return true;
6412 }
6413 40 }
6414
6415 // check enemy weapons true, 1, -1
6416 //
6417
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if((itemsbuf[itemid].flags & item_flag6))
6418 {
6419 if(w->id==wBrang || (w->id==wHookshot&&!pull_hero))
6420 {
6421 int32_t itemid = w->parentitem>-1 ? w->parentitem :
6422 directWpn>-1 ? directWpn : current_item_id(w->id==wHookshot ? (w->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6423 itemid = vbound(itemid, 0, MAXITEMS-1);
6424
6425 for(int32_t j=0; j<Ewpns.Count(); j++)
6426 {
6427 sprite *t = Ewpns.spr(j);
6428
6429 if(w->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6430 {
6431 bool reflect = false;
6432 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6433 if(sh_check(itemsbuf[itemid].misc3, itemsbuf[itemid].misc4, t->id, reflect, ((weapon*)t)->type&1, false))
6434 {
6435 w->dead=1;
6436 weapon *ew = ((weapon*)t);
6437 int32_t oldid = ew->id;
6438 ew->onhit(true, reflect ? 2 : 1, w->dir);
6439 }
6440
6441 break;
6442 }
6443 }
6444 }
6445 }
6446
6447
2/6
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
40 if((itemsbuf[itemid].flags & item_flag2)||(itemid==-1&&get_qr(qr_OUCHBOMBS)))
6448 {
6449 if(((w->id==wBomb)||(w->id==wSBomb)) && !superman && scriptcoldet && !fallclk)
6450 {
6451 bool didhit = w->hit(this);
6452 if(didhit)
6453 {
6454 std::vector<int32_t> &ev = FFCore.eventData;
6455 ev.clear();
6456 ev.push_back(((w->parentitem>-1 ? itemsbuf[w->parentitem].misc3 : w->power) *game->get_hp_per_heart())*10000);
6457 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6458 ev.push_back(0);
6459 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6460 ev.push_back(48*10000);
6461 ev.push_back(ZSD_LWPN*10000);
6462 ev.push_back(w->getUID());
6463 ev.push_back(ZSD_NONE*10000);
6464 ev.push_back(0);
6465
6466 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6467 int32_t dmg = ev[0]/10000;
6468 bool nullhit = ev[2] != 0;
6469
6470 if(nullhit) {ev.clear(); return true;}
6471
6472 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6473 ev[0] = ringpower(dmg)*10000;
6474
6475 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6476 dmg = ev[0]/10000;
6477 int32_t hdir = ev[1]/10000;
6478 nullhit = ev[2] != 0;
6479 bool divineprot = ev[3] != 0;
6480 int32_t iframes = ev[4] / 10000;
6481 ev.clear();
6482 if(nullhit) return true;
6483 if (Lwpns.spr(indx) != w)
6484 {
6485 auto hit = Lwpns.find(w);
6486 if (hit < 0)
6487 w = nullptr;
6488 else
6489 {
6490 w = (weapon*)Lwpns.spr(hit);
6491 indx = hit;
6492 }
6493 }
6494 if(!divineprot)
6495 {
6496 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6497 if (!get_qr(qr_BROKENHITBY) && w)
6498 {
6499 sethitHeroUID(HIT_BY_LWEAPON,(indx+1));
6500 if (get_qr(qr_BROKENHITBY))
6501 {
6502 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6503 }
6504 else
6505 {
6506
6507 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getScriptUID());
6508 }
6509 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6510 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6511 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6512 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6513 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].family);
6514 }
6515 }
6516
6517 hitdir = hdir;
6518
6519 if (action != rafting && action != freeze && action != sideswimfreeze)
6520 {
6521 if (IsSideSwim())
6522 {
6523 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6524 }
6525 else if (action == swimming || hopclk == 0xFF)
6526 {
6527 action=swimhit; FFCore.setHeroAction(swimhit);
6528 }
6529 else
6530 {
6531 action=gothit; FFCore.setHeroAction(gothit);
6532 }
6533 }
6534
6535 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6536 {
6537 spins = charging = attackclk = 0;
6538 attack=none;
6539 tapping = false;
6540 }
6541
6542 hclk=iframes;
6543 sfx(getHurtSFX(),pan(x.getInt()));
6544 return true;
6545 }
6546 }
6547 }
6548
6549
4/8
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 40 times.
40 if(hclk==0 && w->id==wWind && w->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6550 {
6551 std::vector<int32_t> &ev = FFCore.eventData;
6552 ev.clear();
6553 ev.push_back(0);
6554 ev.push_back(w->dir*10000);
6555 ev.push_back(0);
6556 ev.push_back(0);
6557 ev.push_back(ZSD_LWPN*10000);
6558 ev.push_back(w->getUID());
6559 ev.push_back(ZSD_NONE*10000);
6560 ev.push_back(0);
6561
6562 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6563 bool nullhit = ev[2] != 0;
6564 if(nullhit) {ev.clear(); return true;}
6565
6566 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6567 int32_t hdir = ev[1]/10000;
6568 nullhit = ev[2] != 0;
6569 ev.clear();
6570 if(nullhit) return true;
6571 if (Lwpns.spr(indx) != w)
6572 {
6573 auto hit = Lwpns.find(w);
6574 if (hit < 0)
6575 w = nullptr;
6576 else
6577 {
6578 w = (weapon*)Lwpns.spr(hit);
6579 indx = hit;
6580 }
6581 }
6582
6583 reset_hookshot();
6584 xofs=1000;
6585 action=inwind; FFCore.setHeroAction(inwind);
6586 dir = hdir;
6587 if(w) w->dir = hdir;
6588 spins = charging = attackclk = 0;
6589
6590 // In case Hero used two whistles in a row, summoning two whirlwinds,
6591 // check which whistle's whirlwind picked him up so the correct
6592 // warp ring will be used
6593 int32_t whistle = w ? w->parentitem : -1;
6594
6595 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
6596 whistleitem=whistle;
6597
6598 return true;
6599 }
6600 40 return false;
6601 40 }
6602
6603 bool HeroClass::try_ewpn_hit(weapon* w, bool force)
6604 {
6605 if(!force)
6606 {
6607 if(!check_ewpn_collide(w))
6608 return false;
6609 if(w->ignoreHero || w->fallclk|| w->drownclk)
6610 return false;
6611 }
6612 auto indx = Ewpns.find(w);
6613 std::vector<int32_t> &ev = FFCore.eventData;
6614 ev.clear();
6615 ev.push_back((ewpn_dp(indx)*10000));
6616 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6617 ev.push_back(0);
6618 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6619 ev.push_back(48*10000);
6620 ev.push_back(ZSD_EWPN*10000);
6621 ev.push_back(w->getUID());
6622 ev.push_back(ZSD_NONE*10000);
6623 ev.push_back(0);
6624
6625 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6626 int32_t dmg = ev[0]/10000;
6627 bool nullhit = ev[2] != 0;
6628
6629 if(nullhit) {ev.clear(); return false;}
6630
6631 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6632 ev[0] = ringpower(dmg)*10000;
6633
6634 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6635 dmg = ev[0]/10000;
6636 int32_t hdir = ev[1]/10000;
6637 nullhit = ev[2] != 0;
6638 bool divineprot = ev[3] != 0;
6639 int32_t iframes = ev[4] / 10000;
6640 ev.clear();
6641 if (nullhit) return false;
6642 if (Ewpns.spr(indx) != w)
6643 {
6644 indx = Ewpns.find(w);
6645 if (indx < 0)
6646 w = nullptr;
6647 else w = (weapon*)Ewpns.spr(indx);
6648 }
6649 if (!divineprot)
6650 {
6651 game->set_life(zc_max(game->get_life() - dmg, 0));
6652 if (w)
6653 {
6654 sethitHeroUID(HIT_BY_EWEAPON, (indx + 1));
6655 if (get_qr(qr_BROKENHITBY))
6656 {
6657 sethitHeroUID(HIT_BY_EWEAPON_UID, w->getUID());
6658 }
6659 else
6660 {
6661
6662 sethitHeroUID(HIT_BY_EWEAPON_UID, w->getScriptUID());
6663 }
6664 sethitHeroUID(HIT_BY_EWEAPON_ENGINE_UID, w->getUID());
6665 sethitHeroUID(HIT_BY_EWEAPON_TYPE, w->id);
6666 }
6667 }
6668
6669 hitdir = hdir;
6670 if(w)
6671 w->onhit(false);
6672
6673 if (IsSideSwim())
6674 {
6675 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6676 }
6677 else if(action==swimming || hopclk==0xFF)
6678 {
6679 action=swimhit; FFCore.setHeroAction(swimhit);
6680 }
6681 else
6682 {
6683 action=gothit; FFCore.setHeroAction(gothit);
6684 }
6685
6686 hclk=iframes;
6687
6688 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6689 {
6690 spins = charging = attackclk = 0;
6691 attack=none;
6692 tapping = false;
6693 }
6694
6695 sfx(getHurtSFX(),pan(x.getInt()));
6696 return true;
6697 }
6698
6699 20530479 void HeroClass::checkhit()
6700 {
6701
2/2
✓ Branch 0 taken 6360296 times.
✓ Branch 1 taken 14170183 times.
20530479 if(checkhero==true)
6702 {
6703
2/2
✓ Branch 0 taken 13463392 times.
✓ Branch 1 taken 706791 times.
14170183 if(hclk>0)
6704 {
6705 706791 --hclk;
6706 706791 }
6707
6708
1/2
✓ Branch 0 taken 14170183 times.
✗ Branch 1 not taken.
14170183 if(DivineProtectionShieldClk>0)
6709 {
6710 --DivineProtectionShieldClk;
6711
6712 if(DivineProtectionShieldClk == 0 && div_prot_item != -1)
6713 {
6714 stop_sfx(itemsbuf[div_prot_item].usesound);
6715 stop_sfx(itemsbuf[div_prot_item].usesound+1);
6716 div_prot_item = -1;
6717 }
6718 else if(get_qr(qr_MORESOUNDS) && !(DivineProtectionShieldClk&0xF00) && div_prot_item != -1)
6719 {
6720 stop_sfx(itemsbuf[div_prot_item].usesound);
6721 cont_sfx(itemsbuf[div_prot_item].usesound+1);
6722 }
6723 }
6724 14170183 }
6725
6726
4/4
✓ Branch 0 taken 14035044 times.
✓ Branch 1 taken 6495435 times.
✓ Branch 2 taken 14027243 times.
✓ Branch 3 taken 7801 times.
20530479 if(hclk<39 && action==gothit)
6727 {
6728 7801 action=none; FFCore.setHeroAction(none);
6729 7801 }
6730
6731
5/6
✓ Branch 0 taken 14035044 times.
✓ Branch 1 taken 6495435 times.
✓ Branch 2 taken 14034919 times.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14034919 times.
20530479 if(hclk<39 && (action==swimhit || action == sideswimhit))
6732 {
6733 125 SetSwim();
6734 125 }
6735
6736
4/4
✓ Branch 0 taken 120211 times.
✓ Branch 1 taken 20410268 times.
✓ Branch 2 taken 34122 times.
✓ Branch 3 taken 86089 times.
20530479 if(hclk>=40 && action==gothit)
6737 {
6738 86089 int val = check_pitslide();
6739
4/4
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 85661 times.
✓ Branch 2 taken 86265 times.
✓ Branch 3 taken 85837 times.
86089 if(((ladderx+laddery) && ((hitdir&2)==ladderdir))||(!(ladderx+laddery)))
6740 {
6741
2/2
✓ Branch 0 taken 345060 times.
✓ Branch 1 taken 86265 times.
431325 for(int32_t i=0; i<4; i++)
6742 {
6743
5/5
✓ Branch 0 taken 4416 times.
✓ Branch 1 taken 73488 times.
✓ Branch 2 taken 83040 times.
✓ Branch 3 taken 90220 times.
✓ Branch 4 taken 93896 times.
345060 switch(hitdir)
6744 {
6745 case up:
6746
6/6
✓ Branch 0 taken 5359 times.
✓ Branch 1 taken 68129 times.
✓ Branch 2 taken 11472 times.
✓ Branch 3 taken 56657 times.
✓ Branch 4 taken 5501 times.
✓ Branch 5 taken 67987 times.
73488 if(hit_walkflag(x,y+(bigHitbox?-1:7),2)||(x.getInt()&7?hit_walkflag(x+16,y+(bigHitbox?-1:7),1):0))
6747 {
6748 5501 action=none; FFCore.setHeroAction(none);
6749 5501 }
6750
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 67963 times.
67987 else if (val == -1) --y;
6751
6752 73488 break;
6753
6754 case down:
6755
6/6
✓ Branch 0 taken 6883 times.
✓ Branch 1 taken 76157 times.
✓ Branch 2 taken 12972 times.
✓ Branch 3 taken 63185 times.
✓ Branch 4 taken 7041 times.
✓ Branch 5 taken 75999 times.
83040 if(hit_walkflag(x,y+16,2)||(x.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6756 {
6757 7041 action=none; FFCore.setHeroAction(none);
6758 7041 }
6759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75999 times.
75999 else if (val == -1) ++y;
6760
6761 83040 break;
6762
6763 case left:
6764
7/8
✓ Branch 0 taken 86860 times.
✓ Branch 1 taken 3360 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86860 times.
✓ Branch 4 taken 76128 times.
✓ Branch 5 taken 10732 times.
✓ Branch 6 taken 3527 times.
✓ Branch 7 taken 86693 times.
90220 if(hit_walkflag(x-1,y+(bigHitbox?0:8),1)||hit_walkflag(x-1,y+8,1)||(y.getInt()&7?hit_walkflag(x-1,y+16,1):0))
6765 {
6766 3527 action=none; FFCore.setHeroAction(none);
6767 3527 }
6768
2/2
✓ Branch 0 taken 86657 times.
✓ Branch 1 taken 36 times.
86693 else if (val == -1) --x;
6769
6770 90220 break;
6771
6772 case right:
6773
8/8
✓ Branch 0 taken 89850 times.
✓ Branch 1 taken 4046 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 89846 times.
✓ Branch 4 taken 9754 times.
✓ Branch 5 taken 80092 times.
✓ Branch 6 taken 4155 times.
✓ Branch 7 taken 89741 times.
93896 if(hit_walkflag(x+16,y+(bigHitbox?0:8),1)||hit_walkflag(x+16,y+8,1)||(y.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6774 {
6775 4155 action=none; FFCore.setHeroAction(none);
6776 4155 }
6777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89741 times.
89741 else if (val == -1) ++x;
6778
6779 93896 break;
6780 }
6781 345060 }
6782 86265 }
6783 86441 }
6784
6785
19/20
✓ Branch 0 taken 13477740 times.
✓ Branch 1 taken 7053091 times.
✓ Branch 2 taken 13476791 times.
✓ Branch 3 taken 949 times.
✓ Branch 4 taken 13460309 times.
✓ Branch 5 taken 16482 times.
✓ Branch 6 taken 13455789 times.
✓ Branch 7 taken 4520 times.
✓ Branch 8 taken 13455590 times.
✓ Branch 9 taken 199 times.
✓ Branch 10 taken 13455590 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 13454684 times.
✓ Branch 13 taken 906 times.
✓ Branch 14 taken 13444553 times.
✓ Branch 15 taken 10131 times.
✓ Branch 16 taken 11373 times.
✓ Branch 17 taken 13433180 times.
✓ Branch 18 taken 7756751 times.
✓ Branch 19 taken 7768124 times.
20530831 if(hclk>0 || inlikelike == 1 || action==inwind || action==drowning || action==lavadrowning || action==sidedrowning || inwallm || isDiving() || (action==hopping && hopclk<255))
6786 {
6787 14843029 return;
6788 }
6789
6790
2/2
✓ Branch 0 taken 12446233 times.
✓ Branch 1 taken 13433156 times.
25879389 for(int32_t i=0; i<Lwpns.Count(); i++)
6791 {
6792 12446233 sprite *s = Lwpns.spr(i);
6793 12446233 int32_t itemid = ((weapon*)(Lwpns.spr(i)))->parentitem;
6794 //if ( itemdbuf[parentitem].flags&item_flags3 ) //can damage Hero
6795 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6796
12/12
✓ Branch 0 taken 746736 times.
✓ Branch 1 taken 11699497 times.
✓ Branch 2 taken 3931529 times.
✓ Branch 3 taken 7767968 times.
✓ Branch 4 taken 3883555 times.
✓ Branch 5 taken 3884413 times.
✓ Branch 6 taken 3884309 times.
✓ Branch 7 taken 104 times.
✓ Branch 8 taken 91196 times.
✓ Branch 9 taken 3793113 times.
✓ Branch 10 taken 38783 times.
✓ Branch 11 taken 52413 times.
12446233 if((!(itemid==-1&&get_qr(qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & item_flag3)))) && scriptcoldet && !fallclk && (!superman || !get_qr(qr_FIREPROOFHERO2)))
6797 {
6798
9/10
✓ Branch 0 taken 3722428 times.
✓ Branch 1 taken 123098 times.
✓ Branch 2 taken 122655 times.
✓ Branch 3 taken 443 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 443 times.
✓ Branch 6 taken 3711 times.
✓ Branch 7 taken 118944 times.
✓ Branch 8 taken 3844635 times.
✓ Branch 9 taken 33 times.
3848822 if(s->id==wFire && (superman ? (diagonalMovement?s->hit(x+4,y+4-fakez,z,7,7,1):s->hit(x+7,y+7-fakez,z,2,2,1)) : s->hit(this))&&
6799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3296 times.
4154 (itemid < 0 || itemsbuf[itemid].family!=itype_divinefire))
6800 {
6801 33 std::vector<int32_t> &ev = FFCore.eventData;
6802 33 ev.clear();
6803 33 ev.push_back(lwpn_dp(i)*10000);
6804 33 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6805 33 ev.push_back(0);
6806 33 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6807 33 ev.push_back(48*10000);
6808 33 ev.push_back(ZSD_LWPN*10000);
6809 33 ev.push_back(s->getUID());
6810 33 ev.push_back(ZSD_NONE*10000);
6811 33 ev.push_back(0);
6812
6813 33 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6814 33 int32_t dmg = ev[0]/10000;
6815 33 bool nullhit = ev[2] != 0;
6816
6817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(nullhit) {ev.clear(); return;}
6818
6819 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6820 33 ev[0] = ringpower(dmg)*10000;
6821
6822 33 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6823 33 dmg = ev[0]/10000;
6824 33 int32_t hdir = ev[1]/10000;
6825 33 nullhit = ev[2] != 0;
6826 33 bool divineprot = ev[3] != 0;
6827 33 int32_t iframes = ev[4] / 10000;
6828 33 ev.clear();
6829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(nullhit) return;
6830
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if (Lwpns.spr(i) != s)
6831 {
6832 auto hit = Lwpns.find(s);
6833 if (hit < 0)
6834 s = nullptr;
6835 else
6836 {
6837 s = Lwpns.spr(hit);
6838 i = hit;
6839 }
6840 }
6841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!divineprot)
6842 {
6843
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 game->set_life(zc_max(game->get_life()-dmg,0));
6844 33 weapon* w = (weapon*)s;
6845
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33 if (!get_qr(qr_BROKENHITBY) && w)
6846 {
6847 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6848 if (get_qr(qr_BROKENHITBY))
6849 {
6850 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6851 }
6852 else
6853 {
6854
6855 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getScriptUID());
6856 }
6857 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6858 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6859 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6860 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6861 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].family);
6862 }
6863 33 }
6864
6865 33 hitdir = hdir;
6866
6867
3/6
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 33 times.
33 if (action != rafting && action != freeze && action != sideswimfreeze)
6868 {
6869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (IsSideSwim())
6870 {
6871 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6872 }
6873
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 else if (action == swimming || hopclk == 0xFF)
6874 {
6875 action=swimhit; FFCore.setHeroAction(swimhit);
6876 }
6877 else
6878 {
6879 33 action=gothit; FFCore.setHeroAction(gothit);
6880 }
6881 33 }
6882
6883
5/8
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28 times.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 28 times.
33 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6884 {
6885 5 spins = charging = attackclk = 0;
6886 5 attack=none;
6887 5 tapping = false;
6888 5 }
6889
6890 33 hclk=iframes;
6891 33 sfx(getHurtSFX(),pan(x.getInt()));
6892 33 return;
6893 }
6894 3844635 }
6895
6896 // check enemy weapons true, 1, -1
6897 //
6898
2/2
✓ Branch 0 taken 493970 times.
✓ Branch 1 taken 4184262 times.
4678232 if((itemsbuf[itemid].flags & item_flag6))
6899 {
6900
6/6
✓ Branch 0 taken 380644 times.
✓ Branch 1 taken 113326 times.
✓ Branch 2 taken 34343 times.
✓ Branch 3 taken 346301 times.
✓ Branch 4 taken 7231 times.
✓ Branch 5 taken 27112 times.
493970 if(s->id==wBrang || (s->id==wHookshot&&!pull_hero))
6901 {
6902
1/2
✓ Branch 0 taken 140438 times.
✗ Branch 1 not taken.
140438 int32_t itemid = ((weapon*)s)->parentitem>-1 ? ((weapon*)s)->parentitem :
6903 directWpn>-1 ? directWpn : current_item_id(s->id==wHookshot ? (((weapon*)s)->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6904 140438 itemid = vbound(itemid, 0, MAXITEMS-1);
6905
6906
2/2
✓ Branch 0 taken 139950 times.
✓ Branch 1 taken 66159 times.
206109 for(int32_t j=0; j<Ewpns.Count(); j++)
6907 {
6908 66159 sprite *t = Ewpns.spr(j);
6909
6910
2/2
✓ Branch 0 taken 65671 times.
✓ Branch 1 taken 488 times.
66159 if(s->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6911 {
6912 488 bool reflect = false;
6913 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6914
6915
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 119 times.
488 if(sh_check(itemsbuf[itemid].misc3, itemsbuf[itemid].misc4, t->id, reflect, ((weapon*)t)->type&1, false))
6916 {
6917 119 ((weapon*)s)->dead=1;
6918 119 weapon *ew = ((weapon*)t);
6919 119 int32_t oldid = ew->id;
6920 119 ew->onhit(true, reflect ? 2 : 1, s->dir);
6921 119 }
6922 488 break;
6923 }
6924 65671 }
6925 140438 }
6926 493970 }
6927
6928
6/6
✓ Branch 0 taken 3045635 times.
✓ Branch 1 taken 1632597 times.
✓ Branch 2 taken 746736 times.
✓ Branch 3 taken 2298899 times.
✓ Branch 4 taken 106519 times.
✓ Branch 5 taken 640217 times.
4678232 if((itemsbuf[itemid].flags & item_flag2)||(itemid==-1&&get_qr(qr_OUCHBOMBS)))
6929 {
6930
7/8
✓ Branch 0 taken 1693749 times.
✓ Branch 1 taken 45367 times.
✓ Branch 2 taken 45915 times.
✓ Branch 3 taken 1693201 times.
✓ Branch 4 taken 45915 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 29 times.
✓ Branch 7 taken 45886 times.
1739116 if(((s->id==wBomb)||(s->id==wSBomb)) && !superman && scriptcoldet && !fallclk)
6931 {
6932 45886 weapon* w = (weapon*)s;
6933 45886 bool didhit = s->hit(this);
6934
2/2
✓ Branch 0 taken 45851 times.
✓ Branch 1 taken 35 times.
45886 if(didhit)
6935 {
6936 35 std::vector<int32_t> &ev = FFCore.eventData;
6937 35 ev.clear();
6938
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2 times.
35 ev.push_back(((w->parentitem>-1 ? itemsbuf[w->parentitem].misc3 : w->power) *game->get_hp_per_heart())*10000);
6939 35 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6940 35 ev.push_back(0);
6941 35 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6942 35 ev.push_back(48*10000);
6943 35 ev.push_back(ZSD_LWPN*10000);
6944 35 ev.push_back(w->getUID());
6945 35 ev.push_back(ZSD_NONE*10000);
6946 35 ev.push_back(0);
6947
6948 35 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6949 35 int32_t dmg = ev[0]/10000;
6950 35 bool nullhit = ev[2] != 0;
6951
6952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(nullhit) {ev.clear(); return;}
6953
6954 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6955 35 ev[0] = ringpower(dmg)*10000;
6956
6957 35 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6958 35 dmg = ev[0]/10000;
6959 35 int32_t hdir = ev[1]/10000;
6960 35 nullhit = ev[2] != 0;
6961 35 bool divineprot = ev[3] != 0;
6962 35 int32_t iframes = ev[4] / 10000;
6963 35 ev.clear();
6964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(nullhit) return;
6965
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (Lwpns.spr(i) != w)
6966 {
6967 auto hit = Lwpns.find(w);
6968 if (hit < 0)
6969 s = nullptr;
6970 else
6971 {
6972 s = Lwpns.spr(hit);
6973 i = hit;
6974 }
6975 w = (weapon*)s;
6976 }
6977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!divineprot)
6978 {
6979
5/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 1 times.
35 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6980
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
35 if (!get_qr(qr_BROKENHITBY) && w)
6981 {
6982 1 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (get_qr(qr_BROKENHITBY))
6984 {
6985 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6986 }
6987 else
6988 {
6989
6990 1 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getScriptUID());
6991 }
6992 1 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6993 1 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6994
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6995 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6996 1 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].family);
6997 1 }
6998 35 }
6999
7000 35 hitdir = hdir;
7001
7002
3/6
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
35 if (action != rafting && action != freeze && action != sideswimfreeze)
7003 {
7004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if (IsSideSwim())
7005 {
7006 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7007 }
7008
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
35 else if (action == swimming || hopclk == 0xFF)
7009 {
7010 action=swimhit; FFCore.setHeroAction(swimhit);
7011 }
7012 else
7013 {
7014 35 action=gothit; FFCore.setHeroAction(gothit);
7015 }
7016 35 }
7017
7018
5/8
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 34 times.
35 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7019 {
7020 1 spins = charging = attackclk = 0;
7021 1 attack=none;
7022 1 tapping = false;
7023 1 }
7024
7025 35 hclk=iframes;
7026 35 sfx(getHurtSFX(),pan(x.getInt()));
7027 35 return;
7028 }
7029 45851 }
7030 1739081 }
7031
7032
7/8
✓ Branch 0 taken 4678197 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9368 times.
✓ Branch 3 taken 4668829 times.
✓ Branch 4 taken 9256 times.
✓ Branch 5 taken 112 times.
✓ Branch 6 taken 4678085 times.
✓ Branch 7 taken 112 times.
4678197 if(hclk==0 && s->id==wWind && s->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
7033 {
7034 112 std::vector<int32_t> &ev = FFCore.eventData;
7035 112 ev.clear();
7036 112 ev.push_back(0);
7037 112 ev.push_back(s->dir*10000);
7038 112 ev.push_back(0);
7039 112 ev.push_back(0);
7040 112 ev.push_back(ZSD_LWPN*10000);
7041 112 ev.push_back(s->getUID());
7042 112 ev.push_back(ZSD_NONE*10000);
7043 112 ev.push_back(0);
7044
7045 112 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7046 112 bool nullhit = ev[2] != 0;
7047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(nullhit) {ev.clear(); return;}
7048
7049 112 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7050 112 int32_t hdir = ev[1]/10000;
7051 112 nullhit = ev[2] != 0;
7052 112 ev.clear();
7053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(nullhit) return;
7054
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if (Lwpns.spr(i) != s)
7055 {
7056 auto hit = Lwpns.find(s);
7057 if (hit < 0)
7058 s = nullptr;
7059 else
7060 {
7061 s = Lwpns.spr(hit);
7062 i = hit;
7063 }
7064 }
7065
7066 112 reset_hookshot();
7067 112 xofs=1000;
7068 112 action=inwind; FFCore.setHeroAction(inwind);
7069 112 dir = hdir;
7070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(s) s->dir = hdir;
7071 112 spins = charging = attackclk = 0;
7072
7073 // In case Hero used two whistles in a row, summoning two whirlwinds,
7074 // check which whistle's whirlwind picked him up so the correct
7075 // warp ring will be used
7076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 int32_t whistle=s ? ((weapon*)s)->parentitem : -1;
7077
7078
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
112 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
7079 112 whistleitem=whistle;
7080
7081 112 return;
7082 }
7083 4678085 }
7084
7085
6/8
✓ Branch 0 taken 13320294 times.
✓ Branch 1 taken 112862 times.
✓ Branch 2 taken 13012611 times.
✓ Branch 3 taken 307683 times.
✓ Branch 4 taken 13012611 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 13008744 times.
26441900 if(action==rafting || action==freeze || action==sideswimfreeze ||
7086
5/8
✓ Branch 0 taken 13008744 times.
✓ Branch 1 taken 3867 times.
✓ Branch 2 taken 13008744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13008744 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13008744 times.
✗ Branch 7 not taken.
13012611 action==casting || action==sideswimcasting || action==drowning || action==lavadrowning || action==sidedrowning)
7087 424412 return;
7088
7089 13008744 int32_t hit2 = -1;
7090 13008744 do
7091 {
7092
2/2
✓ Branch 0 taken 4176433 times.
✓ Branch 1 taken 8848813 times.
13025246 hit2 = diagonalMovement ? GuyHitFrom(hit2+1,x+4,y+4-fakez,z,8,8,hzsz)
7093 8848813 : GuyHitFrom(hit2+1,x+7,y+7-fakez,z,2,2,hzsz);
7094
7095
2/2
✓ Branch 0 taken 12994569 times.
✓ Branch 1 taken 30677 times.
13025246 if(hit2!=-1)
7096 {
7097
2/2
✓ Branch 0 taken 16502 times.
✓ Branch 1 taken 14175 times.
30677 if (hithero(hit2) == 0) return;
7098 16502 }
7099
2/2
✓ Branch 0 taken 16502 times.
✓ Branch 1 taken 12994569 times.
13011071 } while (hit2 != -1);
7100
6/6
✓ Branch 0 taken 12831516 times.
✓ Branch 1 taken 163053 times.
✓ Branch 2 taken 12821193 times.
✓ Branch 3 taken 10323 times.
✓ Branch 4 taken 3203 times.
✓ Branch 5 taken 12817990 times.
12994569 if (superman || !scriptcoldet || fallclk) return;
7101 12817990 hit2 = LwpnHit();
7102
7103
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 12817980 times.
12817990 if(hit2!=-1)
7104 {
7105 10 weapon* lwpnspr = (weapon*)Lwpns.spr(hit2);
7106 10 std::vector<int32_t> &ev = FFCore.eventData;
7107 10 ev.clear();
7108 10 ev.push_back((lwpn_dp(hit2)*10000));
7109 10 ev.push_back(lwpnspr->hitdir(x,y,16,16,dir)*10000);
7110 10 ev.push_back(0);
7111 10 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7112 10 ev.push_back(48*10000);
7113 10 ev.push_back(ZSD_LWPN*10000);
7114 10 ev.push_back(lwpnspr->getUID());
7115 10 ev.push_back(ZSD_NONE*10000);
7116 10 ev.push_back(0);
7117
7118 10 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7119 10 int32_t dmg = ev[0]/10000;
7120 10 bool nullhit = ev[2] != 0;
7121
7122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(nullhit) {ev.clear(); return;}
7123
7124 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7125 10 ev[0] = ringpower(dmg)*10000;
7126
7127 10 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7128 10 dmg = ev[0]/10000;
7129 10 int32_t hdir = ev[1]/10000;
7130 10 nullhit = ev[2] != 0;
7131 10 bool divineprot = ev[3] != 0;
7132 10 int32_t iframes = ev[4] / 10000;
7133 10 ev.clear();
7134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(nullhit) return;
7135
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if (Lwpns.spr(hit2) != lwpnspr)
7136 {
7137 hit2 = Lwpns.find(lwpnspr);
7138 if (hit2 < 0)
7139 lwpnspr = nullptr;
7140 else lwpnspr = (weapon*)Lwpns.spr(hit2);
7141 }
7142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (!divineprot)
7143 {
7144
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 game->set_life(zc_max(game->get_life() - dmg, 0));
7145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (lwpnspr)
7146 {
7147 10 sethitHeroUID(HIT_BY_LWEAPON, (hit2 + 1));
7148
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
10 if (get_qr(qr_BROKENHITBY))
7149 {
7150 6 sethitHeroUID(HIT_BY_LWEAPON_UID, lwpnspr->getUID());
7151 6 }
7152 else
7153 {
7154
7155 4 sethitHeroUID(HIT_BY_LWEAPON_UID, lwpnspr->getScriptUID());
7156 }
7157 10 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID, lwpnspr->getUID());
7158 10 sethitHeroUID(HIT_BY_LWEAPON_TYPE, lwpnspr->id);
7159
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
10 if (lwpnspr->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, lwpnspr->parentitem);
7160 8 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
7161 10 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[lwpnspr->parentitem].family);
7162 10 }
7163 10 }
7164
7165 10 hitdir = hdir;
7166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(lwpnspr)
7167 10 lwpnspr->onhit(false);
7168
7169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (IsSideSwim())
7170 {
7171 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7172 }
7173
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 else if(action==swimming || hopclk==0xFF)
7174 {
7175 action=swimhit; FFCore.setHeroAction(swimhit);
7176 }
7177 else
7178 {
7179 10 action=gothit; FFCore.setHeroAction(gothit);
7180 }
7181
7182 10 hclk=iframes;
7183
7184
5/8
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
10 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7185 {
7186 7 spins = charging = attackclk = 0;
7187 7 attack=none;
7188 7 tapping = false;
7189 7 }
7190
7191 10 sfx(getHurtSFX(),pan(x.getInt()));
7192 10 return;
7193 }
7194
7195 //else { sethitHeroUID(HIT_BY_LWEAPON,(0)); //fails to clear
7196
7197 12817980 hit2 = EwpnHit();
7198
7199
2/2
✓ Branch 0 taken 5422 times.
✓ Branch 1 taken 12812558 times.
12817980 if(hit2!=-1)
7200 {
7201 5422 weapon* ewpnspr = (weapon*)Ewpns.spr(hit2);
7202 5422 std::vector<int32_t> &ev = FFCore.eventData;
7203 5422 ev.clear();
7204 5422 ev.push_back((ewpn_dp(hit2)*10000));
7205 5422 ev.push_back(ewpnspr->hitdir(x,y,16,16,dir)*10000);
7206 5422 ev.push_back(0);
7207 5422 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7208 5422 ev.push_back(48*10000);
7209 5422 ev.push_back(ZSD_EWPN*10000);
7210 5422 ev.push_back(ewpnspr->getUID());
7211 5422 ev.push_back(ZSD_NONE*10000);
7212 5422 ev.push_back(0);
7213
7214 5422 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7215 5422 int32_t dmg = ev[0]/10000;
7216 5422 bool nullhit = ev[2] != 0;
7217
7218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5422 times.
5422 if(nullhit) {ev.clear(); return;}
7219
7220 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7221 5422 ev[0] = ringpower(dmg)*10000;
7222
7223 5422 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7224 5422 dmg = ev[0]/10000;
7225 5422 int32_t hdir = ev[1]/10000;
7226 5422 nullhit = ev[2] != 0;
7227 5422 bool divineprot = ev[3] != 0;
7228 5422 int32_t iframes = ev[4] / 10000;
7229 5422 ev.clear();
7230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5422 times.
5422 if (nullhit) return;
7231
1/2
✓ Branch 0 taken 5422 times.
✗ Branch 1 not taken.
5422 if (Ewpns.spr(hit2) != ewpnspr)
7232 {
7233 hit2 = Ewpns.find(ewpnspr);
7234 if (hit2 < 0)
7235 ewpnspr = nullptr;
7236 else ewpnspr = (weapon*)Ewpns.spr(hit2);
7237 }
7238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5422 times.
5422 if (!divineprot)
7239 {
7240
2/2
✓ Branch 0 taken 5377 times.
✓ Branch 1 taken 45 times.
5422 game->set_life(zc_max(game->get_life() - dmg, 0));
7241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5422 times.
5422 if (ewpnspr)
7242 {
7243 5422 sethitHeroUID(HIT_BY_EWEAPON, (hit2 + 1));
7244
2/2
✓ Branch 0 taken 5168 times.
✓ Branch 1 taken 254 times.
5422 if (get_qr(qr_BROKENHITBY))
7245 {
7246 5168 sethitHeroUID(HIT_BY_EWEAPON_UID, ewpnspr->getUID());
7247 5168 }
7248 else
7249 {
7250
7251 254 sethitHeroUID(HIT_BY_EWEAPON_UID, ewpnspr->getScriptUID());
7252 }
7253 5422 sethitHeroUID(HIT_BY_EWEAPON_ENGINE_UID, ewpnspr->getUID());
7254 5422 sethitHeroUID(HIT_BY_EWEAPON_TYPE, ewpnspr->id);
7255 5422 }
7256 5422 }
7257
7258 5422 hitdir = hdir;
7259
1/2
✓ Branch 0 taken 5422 times.
✗ Branch 1 not taken.
5422 if(ewpnspr)
7260 5422 ewpnspr->onhit(false);
7261
7262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5422 times.
5422 if (IsSideSwim())
7263 {
7264 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7265 }
7266
3/4
✓ Branch 0 taken 5354 times.
✓ Branch 1 taken 68 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5354 times.
5422 else if(action==swimming || hopclk==0xFF)
7267 {
7268 68 action=swimhit; FFCore.setHeroAction(swimhit);
7269 68 }
7270 else
7271 {
7272 5354 action=gothit; FFCore.setHeroAction(gothit);
7273 }
7274
7275 5422 hclk=iframes;
7276
7277
8/8
✓ Branch 0 taken 5391 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 5390 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1933 times.
✓ Branch 5 taken 3457 times.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 1793 times.
5422 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7278 {
7279 3629 spins = charging = attackclk = 0;
7280 3629 attack=none;
7281 3629 tapping = false;
7282 3629 }
7283
7284 5422 sfx(getHurtSFX(),pan(x.getInt()));
7285 5422 return;
7286 }
7287
7288 // The rest of this method deals with damage combos, which can be jumped over.
7289
4/4
✓ Branch 0 taken 12794647 times.
✓ Branch 1 taken 17911 times.
✓ Branch 2 taken 12794900 times.
✓ Branch 3 taken 17658 times.
12812558 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) return;
7290
7291 12794900 int32_t dx1 = (int32_t)x+8-(tmpscr->csensitive);
7292 12794900 int32_t dx2 = (int32_t)x+8+(tmpscr->csensitive-1);
7293
2/2
✓ Branch 0 taken 235293 times.
✓ Branch 1 taken 12559607 times.
12794900 int32_t dy1 = (int32_t)y+(bigHitbox?8:12)-(bigHitbox?tmpscr->csensitive:(tmpscr->csensitive+1)/2);
7294
2/2
✓ Branch 0 taken 235293 times.
✓ Branch 1 taken 12559607 times.
12794900 int32_t dy2 = (int32_t)y+(bigHitbox?8:12)+(bigHitbox?tmpscr->csensitive-1:((tmpscr->csensitive+1)/2)-1);
7295
7296
2/2
✓ Branch 0 taken 12794900 times.
✓ Branch 1 taken 23648052 times.
36442952 for(int32_t i=get_qr(qr_DMGCOMBOLAYERFIX) ? 1 : -1; i>=-1; i--) // Layers 0, 1 and 2!!
7297 23648052 checkdamagecombos(dx1,dx2,dy1,dy2,i);
7298 14170183 }
7299
7300 16962 bool HeroClass::checkdamagecombos(int32_t dx, int32_t dy)
7301 {
7302 16962 return checkdamagecombos(dx,dx,dy,dy);
7303 }
7304
7305 532 void HeroClass::doHit(int32_t hdir)
7306 {
7307 532 hitdir = hdir;
7308
7309
3/6
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 532 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 532 times.
532 if (action != rafting && action != freeze && action != sideswimfreeze)
7310 {
7311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if (IsSideSwim())
7312 {
7313 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7314 }
7315
2/4
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 532 times.
532 else if (action == swimming || hopclk == 0xFF)
7316 {
7317 action=swimhit; FFCore.setHeroAction(swimhit);
7318 }
7319 else
7320 {
7321 532 action=gothit; FFCore.setHeroAction(gothit);
7322 }
7323 532 }
7324
7325 532 hclk=48;
7326
7327
7/8
✓ Branch 0 taken 530 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 360 times.
✓ Branch 5 taken 170 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 344 times.
532 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7328 {
7329 188 spins = charging = attackclk = 0;
7330 188 attack=none;
7331 188 tapping = false;
7332 188 }
7333
7334 532 sfx(getHurtSFX(),pan(x.getInt()));
7335 532 }
7336
7337 24059428 bool HeroClass::checkdamagecombos(int32_t dx1, int32_t dx2, int32_t dy1, int32_t dy2, int32_t layer, bool solid, bool do_health_check) //layer = -1, solid = false, do_health_check = true
7338 {
7339
5/6
✓ Branch 0 taken 24059162 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 24056971 times.
✓ Branch 3 taken 2191 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24056971 times.
24059428 if(hclk || superman || fallclk)
7340 2457 return false;
7341
7342 24056971 int32_t hp_mod[4] = {0};
7343 int32_t cid[8];
7344 24056971 byte hasKB = 0;
7345
7346 {
7347
2/2
✓ Branch 0 taken 11114459 times.
✓ Branch 1 taken 12942512 times.
24056971 cid[0] = layer>-1?MAPCOMBO2(layer,dx1,dy1):MAPCOMBO(dx1,dy1);
7348 24056971 newcombo& cmb = combobuf[cid[0]];
7349
4/4
✓ Branch 0 taken 24056968 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24055149 times.
✓ Branch 3 taken 1819 times.
24056971 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7350 {
7351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1819 times.
1819 if(cmb.usrflags&cflag1)
7352 hp_mod[0] = cmb.attributes[0] / -10000L;
7353 else
7354 1819 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
7355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1819 times.
1819 if(!(cmb.usrflags&cflag2))
7356 1819 hasKB |= 1<<0;
7357 1819 }
7358 }
7359 {
7360
2/2
✓ Branch 0 taken 11114459 times.
✓ Branch 1 taken 12942512 times.
24056971 cid[1] = layer>-1?MAPCOMBO2(layer,dx1,dy2):MAPCOMBO(dx1,dy2);
7361 24056971 newcombo& cmb = combobuf[cid[1]];
7362
4/4
✓ Branch 0 taken 24056968 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24055103 times.
✓ Branch 3 taken 1865 times.
24056971 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7363 {
7364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1865 times.
1865 if(cmb.usrflags&cflag1)
7365 hp_mod[1] = cmb.attributes[0] / -10000L;
7366 else
7367 1865 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
7368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1865 times.
1865 if(!(cmb.usrflags&cflag2))
7369 1865 hasKB |= 1<<1;
7370 1865 }
7371 }
7372 {
7373
2/2
✓ Branch 0 taken 11114459 times.
✓ Branch 1 taken 12942512 times.
24056971 cid[2] = layer>-1?MAPCOMBO2(layer,dx2,dy1):MAPCOMBO(dx2,dy1);
7374 24056971 newcombo& cmb = combobuf[cid[2]];
7375
4/4
✓ Branch 0 taken 24056968 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24055142 times.
✓ Branch 3 taken 1826 times.
24056971 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7376 {
7377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1826 times.
1826 if(cmb.usrflags&cflag1)
7378 hp_mod[2] = cmb.attributes[0] / -10000L;
7379 else
7380 1826 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
7381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1826 times.
1826 if(!(cmb.usrflags&cflag2))
7382 1826 hasKB |= 1<<2;
7383 1826 }
7384 }
7385 {
7386
2/2
✓ Branch 0 taken 11114459 times.
✓ Branch 1 taken 12942512 times.
24056971 cid[3] = layer>-1?MAPCOMBO2(layer,dx2,dy2):MAPCOMBO(dx2,dy2);
7387 24056971 newcombo& cmb = combobuf[cid[3]];
7388
4/4
✓ Branch 0 taken 24056968 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24055085 times.
✓ Branch 3 taken 1883 times.
24056971 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7389 {
7390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1883 times.
1883 if(cmb.usrflags&cflag1)
7391 hp_mod[3] = cmb.attributes[0] / -10000L;
7392 else
7393 1883 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
7394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1883 times.
1883 if(!(cmb.usrflags&cflag2))
7395 1883 hasKB |= 1<<3;
7396 1883 }
7397 }
7398
7399 24056971 int32_t bestcid=0;
7400 24056971 int best_cpos = -1;
7401 24056971 int32_t hp_modtotal=0;
7402 24056971 int poses[8] = {COMBOPOS(dx1,dy1),COMBOPOS(dx1,dy2),COMBOPOS(dx2,dy1),COMBOPOS(dx2,dy2)};
7403
2/2
✓ Branch 0 taken 17465538 times.
✓ Branch 1 taken 6591433 times.
24056971 if (!_effectflag(dx1,dy1,1, layer)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
7404
2/2
✓ Branch 0 taken 17457088 times.
✓ Branch 1 taken 6599883 times.
24056971 if (!_effectflag(dx1,dy2,1, layer)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
7405
2/2
✓ Branch 0 taken 17465564 times.
✓ Branch 1 taken 6591407 times.
24056971 if (!_effectflag(dx2,dy1,1, layer)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
7406
2/2
✓ Branch 0 taken 17457114 times.
✓ Branch 1 taken 6599857 times.
24056971 if (!_effectflag(dx2,dy2,1, layer)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7407
7408
2/2
✓ Branch 0 taken 48113942 times.
✓ Branch 1 taken 24056971 times.
72170913 for (int32_t i = 0; i <= 1; ++i)
7409 {
7410
2/2
✓ Branch 0 taken 31455599 times.
✓ Branch 1 taken 16658343 times.
48113942 if(tmpscr2[i].valid!=0)
7411 {
7412
2/2
✓ Branch 0 taken 13156917 times.
✓ Branch 1 taken 3501426 times.
16658343 if (get_qr(qr_OLD_BRIDGE_COMBOS))
7413 {
7414
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
7415
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
7416
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
7417
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7418 13156917 }
7419 else
7420 {
7421
4/4
✓ Branch 0 taken 10124 times.
✓ Branch 1 taken 3491302 times.
✓ Branch 2 taken 2538 times.
✓ Branch 3 taken 7586 times.
3501426 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
7422
4/4
✓ Branch 0 taken 10154 times.
✓ Branch 1 taken 3491272 times.
✓ Branch 2 taken 2598 times.
✓ Branch 3 taken 7556 times.
3501426 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
7423
4/4
✓ Branch 0 taken 10148 times.
✓ Branch 1 taken 3491278 times.
✓ Branch 2 taken 2622 times.
✓ Branch 3 taken 7526 times.
3501426 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
7424
4/4
✓ Branch 0 taken 10181 times.
✓ Branch 1 taken 3491245 times.
✓ Branch 2 taken 2685 times.
✓ Branch 3 taken 7496 times.
3501426 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7425 }
7426 16658343 }
7427 48113942 }
7428
7429
2/2
✓ Branch 0 taken 96227884 times.
✓ Branch 1 taken 24056971 times.
120284855 for(int32_t i=0; i<4; i++)
7430 {
7431
2/2
✓ Branch 0 taken 37140136 times.
✓ Branch 1 taken 59087748 times.
96227884 if(get_qr(qr_DMGCOMBOPRI))
7432 {
7433
2/2
✓ Branch 0 taken 37139750 times.
✓ Branch 1 taken 386 times.
37140136 if(hp_modtotal >= 0) //Okay, if it's over 0, it's healing Hero.
7434 {
7435
2/2
✓ Branch 0 taken 37139592 times.
✓ Branch 1 taken 158 times.
37139750 if(hp_mod[i] < hp_modtotal)
7436 {
7437 158 hp_modtotal = hp_mod[i];
7438 158 bestcid = cid[i];
7439 158 best_cpos = poses[i];
7440 158 }
7441 37139750 }
7442
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 88 times.
386 else if(hp_mod[i] < 0) //If it's under 0, it's hurting Hero.
7443 {
7444
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 if(hp_mod[i] > hp_modtotal)
7445 {
7446 hp_modtotal = hp_mod[i];
7447 bestcid = cid[i];
7448 best_cpos = poses[i];
7449 }
7450 298 }
7451 37140136 }
7452
2/2
✓ Branch 0 taken 59085824 times.
✓ Branch 1 taken 1924 times.
59087748 else if(hp_mod[i] < hp_modtotal)
7453 {
7454 1924 hp_modtotal = hp_mod[i];
7455 1924 bestcid = cid[i];
7456 1924 best_cpos = poses[i];
7457 1924 }
7458 96227884 }
7459
7460 {
7461 24056971 poses[4] = getFFCAt(dx1,dy1);
7462
2/2
✓ Branch 0 taken 384757 times.
✓ Branch 1 taken 23672214 times.
24056971 cid[4] = poses[4] > -1 ? tmpscr->ffcs[poses[4]].data : 0;
7463 24056971 newcombo& cmb = combobuf[cid[4]];
7464
4/4
✓ Branch 0 taken 24056776 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 24056725 times.
✓ Branch 3 taken 51 times.
24056971 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7465 {
7466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(cmb.usrflags&cflag1 )
7467 hp_mod[0] = cmb.attributes[0]/-10000L;
7468 else
7469 51 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
7470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(!(cmb.usrflags&cflag2))
7471 51 hasKB |= 1<<4;
7472 51 }
7473 }
7474 {
7475 24056971 poses[5] = getFFCAt(dx1,dy2);
7476
2/2
✓ Branch 0 taken 381758 times.
✓ Branch 1 taken 23675213 times.
24056971 cid[5] = poses[5] > -1 ? tmpscr->ffcs[poses[5]].data : 0;
7477 24056971 newcombo& cmb = combobuf[cid[5]];
7478
4/4
✓ Branch 0 taken 24056767 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 24056720 times.
✓ Branch 3 taken 47 times.
24056971 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7479 {
7480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(cmb.usrflags&cflag1 )
7481 hp_mod[1] = cmb.attributes[0]/-10000L;
7482 else
7483 47 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
7484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(!(cmb.usrflags&cflag2))
7485 47 hasKB |= 1<<5;
7486 47 }
7487 }
7488 {
7489 24056971 poses[6] = getFFCAt(dx2,dy1);
7490
2/2
✓ Branch 0 taken 388853 times.
✓ Branch 1 taken 23668118 times.
24056971 cid[6] = poses[6] > -1 ? tmpscr->ffcs[poses[6]].data : 0;
7491 24056971 newcombo& cmb = combobuf[cid[6]];
7492
4/4
✓ Branch 0 taken 24056779 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 24056732 times.
✓ Branch 3 taken 47 times.
24056971 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7493 {
7494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(cmb.usrflags&cflag1 )
7495 hp_mod[2] = cmb.attributes[0]/-10000L;
7496 else
7497 47 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
7498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(!(cmb.usrflags&cflag2))
7499 47 hasKB |= 1<<6;
7500 47 }
7501 }
7502 {
7503 24056971 poses[7] = getFFCAt(dx2,dy2);
7504
2/2
✓ Branch 0 taken 385812 times.
✓ Branch 1 taken 23671159 times.
24056971 cid[7] = poses[7] > -1 ? tmpscr->ffcs[poses[7]].data : 0;
7505 24056971 newcombo& cmb = combobuf[cid[7]];
7506
4/4
✓ Branch 0 taken 24056770 times.
✓ Branch 1 taken 201 times.
✓ Branch 2 taken 24056725 times.
✓ Branch 3 taken 45 times.
24056971 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7507 {
7508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(cmb.usrflags&cflag1 )
7509 hp_mod[3] = cmb.attributes[0]/-10000L;
7510 else
7511 45 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
7512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(!(cmb.usrflags&cflag2))
7513 45 hasKB |= 1<<7;
7514 45 }
7515 }
7516
7517 24056971 int32_t bestffccid = 0;
7518 24056971 int best_ffcpos = -1;
7519 24056971 int32_t hp_modtotalffc = 0;
7520
7521
2/2
✓ Branch 0 taken 48113942 times.
✓ Branch 1 taken 24056971 times.
72170913 for (int32_t i = 0; i <= 1; ++i)
7522 {
7523
2/2
✓ Branch 0 taken 31455599 times.
✓ Branch 1 taken 16658343 times.
48113942 if(tmpscr2[i].valid!=0)
7524 {
7525
2/2
✓ Branch 0 taken 13156917 times.
✓ Branch 1 taken 3501426 times.
16658343 if (get_qr(qr_OLD_BRIDGE_COMBOS))
7526 {
7527
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7528
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7529
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7530
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7531 13156917 }
7532 else
7533 {
7534
4/4
✓ Branch 0 taken 10124 times.
✓ Branch 1 taken 3491302 times.
✓ Branch 2 taken 2538 times.
✓ Branch 3 taken 7586 times.
3501426 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7535
4/4
✓ Branch 0 taken 10154 times.
✓ Branch 1 taken 3491272 times.
✓ Branch 2 taken 2598 times.
✓ Branch 3 taken 7556 times.
3501426 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7536
4/4
✓ Branch 0 taken 10148 times.
✓ Branch 1 taken 3491278 times.
✓ Branch 2 taken 2622 times.
✓ Branch 3 taken 7526 times.
3501426 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7537
4/4
✓ Branch 0 taken 10181 times.
✓ Branch 1 taken 3491245 times.
✓ Branch 2 taken 2685 times.
✓ Branch 3 taken 7496 times.
3501426 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7538 }
7539 16658343 }
7540 48113942 }
7541
7542
2/2
✓ Branch 0 taken 96227884 times.
✓ Branch 1 taken 24056971 times.
120284855 for(int32_t i=0; i<4; i++)
7543 {
7544
2/2
✓ Branch 0 taken 1541180 times.
✓ Branch 1 taken 94686704 times.
96227884 if(poses[i+4] < 0) continue;
7545
2/2
✓ Branch 0 taken 224021 times.
✓ Branch 1 taken 1317159 times.
1541180 if(get_qr(qr_DMGCOMBOPRI))
7546 {
7547
2/2
✓ Branch 0 taken 223905 times.
✓ Branch 1 taken 116 times.
224021 if(hp_modtotalffc >= 0)
7548 {
7549
2/2
✓ Branch 0 taken 223840 times.
✓ Branch 1 taken 65 times.
223905 if(hp_mod[i] < hp_modtotalffc)
7550 {
7551 65 hp_modtotalffc = hp_mod[i];
7552 65 bestffccid = cid[4+i];
7553 65 best_ffcpos = poses[4+i];
7554 65 }
7555 223905 }
7556
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 112 times.
116 else if(hp_mod[i] < 0)
7557 {
7558
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(hp_mod[i] > hp_modtotalffc)
7559 {
7560 hp_modtotalffc = hp_mod[i];
7561 bestffccid = cid[4+i];
7562 best_ffcpos = poses[4+i];
7563 }
7564 112 }
7565 224021 }
7566
2/2
✓ Branch 0 taken 1317130 times.
✓ Branch 1 taken 29 times.
1317159 else if(hp_mod[i] < hp_modtotalffc)
7567 {
7568 29 hp_modtotalffc = hp_mod[i];
7569 29 bestffccid = cid[4+i];
7570 29 best_ffcpos = poses[4+i];
7571 29 }
7572 1541180 }
7573
7574
2/2
✓ Branch 0 taken 2058 times.
✓ Branch 1 taken 24054913 times.
24056971 int32_t hp_modmin = zc_min(hp_modtotal, hp_modtotalffc);
7575 24056971 int best_type = 0;
7576
2/2
✓ Branch 0 taken 24056901 times.
✓ Branch 1 taken 70 times.
24056971 if(hp_modtotalffc < hp_modtotal)
7577 {
7578 70 bestcid = bestffccid;
7579 70 best_type = 1;
7580 70 }
7581
7582 24056971 bool global_defring = ((itemsbuf[current_item_id(itype_ring)].flags & item_flag1));
7583 24056971 bool global_perilring = ((itemsbuf[current_item_id(itype_perilring)].flags & item_flag1));
7584 24056971 bool current_ring = ((tmpscr->flags6&fTOGGLERINGDAMAGE) != 0);
7585
1/2
✓ Branch 0 taken 24056971 times.
✗ Branch 1 not taken.
24056971 if(current_ring)
7586 {
7587 global_defring = !global_defring;
7588 global_perilring = !global_perilring;
7589 }
7590 24056971 int32_t itemid = current_item_id(itype_boots);
7591
7592
2/2
✓ Branch 0 taken 23221123 times.
✓ Branch 1 taken 835848 times.
24056971 bool bootsnosolid = itemid >= 0 && 0 != (itemsbuf[itemid].flags & item_flag1);
7593
2/2
✓ Branch 0 taken 23221123 times.
✓ Branch 1 taken 835848 times.
24056971 bool ignoreBoots = itemid >= 0 && (itemsbuf[itemid].flags & item_flag3);
7594
7595
2/2
✓ Branch 0 taken 24054829 times.
✓ Branch 1 taken 2142 times.
24056971 if(hp_modmin<0)
7596 {
7597
10/14
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 528 times.
✓ Branch 2 taken 1614 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1614 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1614 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 1609 times.
✓ Branch 10 taken 1614 times.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1614 times.
2142 if((itemid<0) || ignoreBoots || (tmpscr->flags5&fDAMAGEWITHBOOTS) || (4<<current_item_power(itype_boots)<(abs(hp_modmin))) || (solid && bootsnosolid) || !(checkbunny(itemid) && checkmagiccost(itemid)))
7598 {
7599
2/2
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 6 times.
538 if (!do_health_check) return true;
7600 532 std::vector<int32_t> &ev = FFCore.eventData;
7601 532 ev.clear();
7602 532 ev.push_back(-hp_modmin*10000);
7603
1/2
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
532 ev.push_back((hasKB ? dir^1 : -1)*10000);
7604 532 ev.push_back(0);
7605 532 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7606 532 ev.push_back(48*10000);
7607 532 ev.push_back(ZSD_COMBODATA*10000);
7608 532 ev.push_back(bestcid);
7609 532 ev.push_back((best_type ? ZSD_FFC : ZSD_COMBOPOS)*10000);
7610
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 462 times.
532 ev.push_back(best_type ? best_ffcpos : best_cpos*10000);
7611
7612 532 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7613 532 int32_t dmg = ev[0]/10000;
7614 532 bool nullhit = ev[2] != 0;
7615
7616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(nullhit) {ev.clear(); return false;}
7617
7618 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7619 532 ev[0] = ringpower(dmg, !global_perilring, !global_defring)*10000;
7620
7621 532 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7622 532 dmg = ev[0]/10000;
7623 532 int32_t hdir = ev[1]/10000;
7624 532 nullhit = ev[2] != 0;
7625 532 bool divineprot = ev[3] != 0;
7626 532 int32_t iframes = ev[4] / 10000;
7627 532 ev.clear();
7628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(nullhit) return false;
7629
7630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(!divineprot)
7631 {
7632
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 19 times.
532 game->set_life(zc_max(game->get_life()-dmg,0));
7633 532 }
7634
7635 532 hitdir = hdir;
7636 532 doHit(hitdir);
7637 532 hclk = iframes;
7638 532 return true;
7639 }
7640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1614 times.
1614 else if (do_health_check) paymagiccost(itemid); // Boots are successful
7641 1614 }
7642
7643 24056443 return false;
7644 24059438 }
7645
7646 30834 int32_t HeroClass::hithero(int32_t hit2, int32_t force_hdir)
7647 {
7648
1/2
✓ Branch 0 taken 30834 times.
✗ Branch 1 not taken.
30834 if(force_hdir > 3) force_hdir = -1;
7649 30834 enemy* enemyptr = (enemy*)guys.spr(hit2);
7650
1/2
✓ Branch 0 taken 30834 times.
✗ Branch 1 not taken.
30834 if(!enemyptr) return 0;
7651 //printf("Stomp check: %d <= 12, %d < %d\n", int32_t((y+16)-(((enemy*)guys.spr(hit2))->y)), (int32_t)falling_oldy, (int32_t)y);
7652 30834 int32_t stompid = current_item_id(itype_stompboots);
7653
5/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 30819 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
30834 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
7654
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 ((z+fakez) > (enemyptr->z+(enemyptr->fakez))) ||
7655
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 ((isSideViewHero() && (y+16)-(enemyptr->y)<=14) && falling_oldy<y)))
7656 {
7657 paymagiccost(stompid);
7658 hit_enemy(hit2,wStomp,itemsbuf[stompid].power*game->get_hero_dmgmult(),x,y,0,stompid);
7659
7660 if(itemsbuf[stompid].flags & item_flag1)
7661 {
7662 fall = -(itemsbuf[stompid].misc1);
7663 }
7664
7665 if(itemsbuf[stompid].flags & item_downgrade)
7666 game->set_item(stompid,false);
7667
7668 // Stomp Boots script
7669 if(itemsbuf[stompid].script != 0 && !(FFCore.doscript(ScriptType::Item, stompid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
7670 {
7671 int i = stompid;
7672 FFCore.reset_script_engine_data(ScriptType::Item, i);
7673 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[stompid].script, i);
7674 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
7675 }
7676
7677 return -1;
7678 }
7679
6/6
✓ Branch 0 taken 26573 times.
✓ Branch 1 taken 4261 times.
✓ Branch 2 taken 25785 times.
✓ Branch 3 taken 788 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 25738 times.
30834 else if(superman || !scriptcoldet || fallclk)
7680 5096 return 0;
7681 //!TODO SOLIDPUSH Enemy flag to make them not deal contact damage
7682 //!Add a flag check to this if:
7683
5/6
✓ Branch 0 taken 9384 times.
✓ Branch 1 taken 16354 times.
✓ Branch 2 taken 9384 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2619 times.
✓ Branch 5 taken 6765 times.
25740 else if (!(enemyptr->stunclk==0 && enemyptr->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || enemyptr->fading != fade_flicker)
7684
4/4
✓ Branch 0 taken 2374 times.
✓ Branch 1 taken 245 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 9137 times.
9384 && (enemyptr->d->family != eeGUY || enemyptr->dmisc1)))
7685 {
7686 16599 return -1;
7687 }
7688
7689 9139 std::vector<int32_t> &ev = FFCore.eventData;
7690 9139 ev.clear();
7691 //Args: 'damage (pre-ring)','hitdir','nullifyhit','type:npc','npc uid'
7692 9139 ev.push_back((enemy_dp(hit2) *10000));
7693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9139 times.
9139 ev.push_back((force_hdir>-1 ? force_hdir : ((sprite*)enemyptr)->hitdir(x,y,16,16,dir))*10000);
7694 9139 ev.push_back(0);
7695 9139 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7696 9139 ev.push_back(48*10000);
7697 9139 ev.push_back(ZSD_NPC*10000);
7698 9139 ev.push_back(enemyptr->getUID());
7699 9139 ev.push_back(ZSD_NONE*10000);
7700 9139 ev.push_back(0);
7701
7702 9139 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7703 9139 int32_t dmg = ev[0] / 10000;
7704 9139 bool nullhit = ev[2] != 0;
7705
7706
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9138 times.
9139 if(nullhit) {ev.clear(); return -1;}
7707
7708 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7709 9138 ev[0] = ((ringpower(dmg)*10000));
7710
7711 9138 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7712 9138 dmg = ev[0] / 10000;
7713 9138 int32_t hdir = ev[1] / 10000;
7714 9138 nullhit = ev[2] != 0;
7715 9138 bool divineprot = ev[3] != 0;
7716 9138 int32_t iframes = ev[4] / 10000;
7717 9138 ev.clear();
7718
7719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9138 times.
9138 if(nullhit) return -1;
7720
7721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9138 times.
9138 if(!divineprot)
7722 {
7723
2/2
✓ Branch 0 taken 9084 times.
✓ Branch 1 taken 54 times.
9138 game->set_life(zc_max(game->get_life()-dmg,0));
7724 9138 sethitHeroUID(HIT_BY_NPC,(hit2+1));
7725 9138 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7726
2/2
✓ Branch 0 taken 8901 times.
✓ Branch 1 taken 237 times.
9138 if (get_qr(qr_BROKENHITBY))
7727 {
7728 8901 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7729 8901 }
7730 else
7731 {
7732 237 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->script_UID);
7733 }
7734 9138 sethitHeroUID(HIT_BY_NPC_ENGINE_UID,enemyptr->getUID());
7735 9138 sethitHeroUID(HIT_BY_NPC_ID, enemyptr->id);
7736 9138 sethitHeroUID(HIT_BY_NPC_TYPE, enemyptr->family);
7737 9138 }
7738
7739 9138 hitdir = hdir;
7740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9138 times.
9138 if (IsSideSwim())
7741 {
7742 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7743 }
7744
3/4
✓ Branch 0 taken 9068 times.
✓ Branch 1 taken 70 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9068 times.
9138 else if(action==swimming || hopclk==0xFF)
7745 {
7746 70 action=swimhit; FFCore.setHeroAction(swimhit);
7747 70 }
7748 else
7749 {
7750 9068 action=gothit; FFCore.setHeroAction(gothit);
7751 }
7752
7753 9138 hclk=iframes;
7754 9138 sfx(getHurtSFX(),pan(x.getInt()));
7755
7756
8/8
✓ Branch 0 taken 9114 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 9111 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3757 times.
✓ Branch 5 taken 5354 times.
✓ Branch 6 taken 158 times.
✓ Branch 7 taken 3599 times.
9138 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7757 {
7758 5539 spins = charging = attackclk = 0;
7759 5539 attack=none;
7760 5539 tapping = false;
7761 5539 }
7762
7763 9138 enemy_scored(hit2);
7764 9138 int32_t dm7 = enemyptr->dmisc7;
7765 9138 int32_t dm8 = enemyptr->dmisc8;
7766
7767
3/3
✓ Branch 0 taken 4457 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 4672 times.
9138 switch(enemyptr->family)
7768 {
7769 case eeWALLM:
7770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(enemyptr->hp>0)
7771 {
7772 9 GrabHero(hit2);
7773 9 inwallm=true;
7774 9 action=none; FFCore.setHeroAction(none);
7775 9 }
7776 9 break;
7777
7778 //case eBUBBLEST:
7779 //case eeBUBBLE:
7780 case eeWALK:
7781 {
7782 4672 int32_t itemid = current_item_id(itype_whispring);
7783 //I can only assume these are supposed to be int32_t, not bool ~pkmnfrk
7784
3/4
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 3797 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 875 times.
4672 int32_t sworddivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 1) ? itemsbuf[itemid].power : 1);
7785
3/4
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 3797 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 875 times.
4672 int32_t itemdivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 2) ? itemsbuf[itemid].power : 1);
7786
3/4
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 3797 times.
✓ Branch 2 taken 875 times.
✗ Branch 3 not taken.
4672 int32_t shielddivisor = ((itemid > -1 && itemsbuf[itemid].misc1 & 4) ? itemsbuf[itemid].power : 1);
7787
7/7
✓ Branch 0 taken 3791 times.
✓ Branch 1 taken 448 times.
✓ Branch 2 taken 145 times.
✓ Branch 3 taken 256 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 6 times.
4672 switch(dm7)
7788 {
7789 case e7tTEMPJINX:
7790
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 400 times.
448 if(dm8&e8tSWORD)
7791
4/4
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 386 times.
786 if(swordclk>=0 && !(sworddivisor==0))
7792 386 swordclk=int32_t(150/sworddivisor);
7793
7794
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 50 times.
448 if(dm8&e8tITEM)
7795
3/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 49 times.
99 if(itemclk>=0 && !(itemdivisor==0))
7796 49 itemclk=int32_t(150/itemdivisor);
7797
7798
1/2
✓ Branch 0 taken 448 times.
✗ Branch 1 not taken.
448 if(dm8&e8tSHIELD)
7799 if (shieldjinxclk >= 0 && !(shielddivisor==0))
7800 shieldjinxclk=int32_t(150/shielddivisor);
7801
7802 448 break;
7803
7804 case e7tPERMJINX:
7805
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 99 times.
145 if (dm8&e8tSWORD)
7806
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 93 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
99 if(sworddivisor) swordclk=(itemid >-1 && itemsbuf[itemid].flags & item_flag1)? int32_t(150/sworddivisor) : -1;
7807
7808
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 46 times.
145 if (dm8&e8tITEM)
7809
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
46 if(itemdivisor) itemclk=(itemid >-1 && itemsbuf[itemid].flags & item_flag1)? int32_t(150/itemdivisor) : -1;
7810
7811
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 if (dm8&e8tSHIELD)
7812 if(shielddivisor) shieldjinxclk=(itemid >-1 && itemsbuf[itemid].flags & item_flag1)? int32_t(150/shielddivisor) : -1;
7813
7814 145 break;
7815
7816 case e7tUNJINX:
7817
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 199 times.
256 if (dm8&e8tSWORD)
7818 199 swordclk=0;
7819
7820
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 76 times.
256 if (dm8&e8tITEM)
7821 76 itemclk=0;
7822
7823
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if (dm8&e8tSHIELD)
7824 shieldjinxclk=0;
7825
7826 256 break;
7827
7828 case e7tTAKEMAGIC:
7829 5 game->change_dmagic(-dm8*game->get_magicdrainrate());
7830 5 break;
7831
7832 case e7tTAKERUPEES:
7833 21 game->change_drupy(-dm8);
7834 21 break;
7835
7836 case e7tDRUNK:
7837 6 drunkclk += dm8;
7838 6 break;
7839 }
7840 4672 verifyAWpn();
7841
2/2
✓ Branch 0 taken 4534 times.
✓ Branch 1 taken 138 times.
4672 if(dm7 >= e7tEATITEMS)
7842 {
7843 138 EatHero(hit2);
7844 138 inlikelike=(dm7 == e7tEATHURT ? 2:1);
7845 138 action=none; FFCore.setHeroAction(none);
7846 138 }
7847 }
7848 4672 }
7849 9138 return 0;
7850 30834 }
7851
7852 513551 void HeroClass::addsparkle(int32_t wpn)
7853 {
7854 //return;
7855 513551 weapon *w = (weapon*)Lwpns.spr(wpn);
7856 513551 int32_t itemid = w->parentitem;
7857
7858
2/2
✓ Branch 0 taken 508050 times.
✓ Branch 1 taken 5501 times.
513551 if(itemid<0)
7859 5501 return;
7860
7861 508050 int32_t itemtype = itemsbuf[itemid].family;
7862
7863
4/4
✓ Branch 0 taken 507977 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 127016 times.
✓ Branch 3 taken 380961 times.
508050 if(itemtype!=itype_cbyrna && frame%4)
7864 380961 return;
7865
7866
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 127016 times.
127089 int32_t wpn2 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn4 : itemsbuf[itemid].wpn2;
7867
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 127016 times.
127089 int32_t wpn3 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn5 : itemsbuf[itemid].wpn3;
7868 // Either one (wpn2) or the other (wpn3). If both are present, randomise.
7869
5/8
✓ Branch 0 taken 37740 times.
✓ Branch 1 taken 89349 times.
✓ Branch 2 taken 69175 times.
✓ Branch 3 taken 20174 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 37740 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
127089 int32_t sparkle_type = (!wpn2 ? (!wpn3 ? 0 : wpn3) : (!wpn3 ? wpn2 : (zc_oldrand()&1 ? wpn2 : wpn3)));
7870 127089 int32_t direction=w->dir;
7871
7872
2/2
✓ Branch 0 taken 69175 times.
✓ Branch 1 taken 57914 times.
127089 if(sparkle_type)
7873 {
7874 57914 int32_t h=0;
7875 57914 int32_t v=0;
7876
7877
6/6
✓ Branch 0 taken 45738 times.
✓ Branch 1 taken 12176 times.
✓ Branch 2 taken 40646 times.
✓ Branch 3 taken 5092 times.
✓ Branch 4 taken 7701 times.
✓ Branch 5 taken 32945 times.
57914 if(w->dir==right||w->dir==r_up||w->dir==r_down)
7878 {
7879 24969 h=-1;
7880 24969 }
7881
7882
6/6
✓ Branch 0 taken 46119 times.
✓ Branch 1 taken 11795 times.
✓ Branch 2 taken 39437 times.
✓ Branch 3 taken 6682 times.
✓ Branch 4 taken 5665 times.
✓ Branch 5 taken 33772 times.
57914 if(w->dir==left||w->dir==l_up||w->dir==l_down)
7883 {
7884 24142 h=1;
7885 24142 }
7886
7887
6/6
✓ Branch 0 taken 54015 times.
✓ Branch 1 taken 3899 times.
✓ Branch 2 taken 48350 times.
✓ Branch 3 taken 5665 times.
✓ Branch 4 taken 7701 times.
✓ Branch 5 taken 40649 times.
57914 if(w->dir==down||w->dir==l_down||w->dir==r_down)
7888 {
7889 17265 v=-1;
7890 17265 }
7891
7892
6/6
✓ Branch 0 taken 53010 times.
✓ Branch 1 taken 4904 times.
✓ Branch 2 taken 46328 times.
✓ Branch 3 taken 6682 times.
✓ Branch 4 taken 5092 times.
✓ Branch 5 taken 41236 times.
57914 if(w->dir==up||w->dir==l_up||w->dir==r_up)
7893 {
7894 16678 v=1;
7895 16678 }
7896
7897 // Damaging boomerang sparkle?
7898
3/4
✓ Branch 0 taken 20174 times.
✓ Branch 1 taken 37740 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20174 times.
57914 if(wpn3 && itemtype==itype_brang)
7899 {
7900 // If the boomerang just bounced, flip the sparkle direction so it doesn't hit
7901 // whatever it just bounced off of if it's shielded from that direction.
7902
6/6
✓ Branch 0 taken 13170 times.
✓ Branch 1 taken 7004 times.
✓ Branch 2 taken 12323 times.
✓ Branch 3 taken 847 times.
✓ Branch 4 taken 5336 times.
✓ Branch 5 taken 6987 times.
20174 if(w->misc==1 && w->clk2>256 && w->clk2<272)
7903 6987 direction=oppositeDir[direction];
7904 20174 }
7905
4/4
✓ Branch 0 taken 53641 times.
✓ Branch 1 taken 4273 times.
✓ Branch 2 taken 23899 times.
✓ Branch 3 taken 29742 times.
57914 if(itemtype==itype_brang && get_qr(qr_WRONG_BRANG_TRAIL_DIR)) direction = 0;
7906
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 57841 times.
57914 zfix x = w->x+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(h*4);
7907
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 57841 times.
57914 zfix y = w->y+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(v*4)-w->fakez;
7908
5/10
✓ Branch 0 taken 57914 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57914 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57914 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 57914 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 57914 times.
✗ Branch 9 not taken.
57914 Lwpns.add(new weapon(x, y, w->z, sparkle_type==wpn3 ? wFSparkle : wSSparkle,sparkle_type,0,direction,itemid,getUID(),false,false,true, 0, sparkle_type));
7909 57914 weapon *w = (weapon*)(Lwpns.spr(Lwpns.Count()-1));
7910 57914 }
7911 513551 }
7912
7913 // For wPhantoms
7914 7410 void HeroClass::addsparkle2(int32_t type1, int32_t type2)
7915 {
7916
2/2
✓ Branch 0 taken 5586 times.
✓ Branch 1 taken 1824 times.
7410 if(frame%4) return;
7917
7918 1824 int32_t arrow = -1;
7919
7920
2/2
✓ Branch 0 taken 1520 times.
✓ Branch 1 taken 10041 times.
11561 for(int32_t i=0; i<Lwpns.Count(); i++)
7921 {
7922 10041 weapon *w = (weapon*)Lwpns.spr(i);
7923
7924
4/4
✓ Branch 0 taken 6249 times.
✓ Branch 1 taken 3792 times.
✓ Branch 2 taken 5945 times.
✓ Branch 3 taken 304 times.
10041 if(w->id == wPhantom && w->type == type1)
7925 {
7926 304 arrow = i;
7927 304 break;
7928 }
7929 9737 }
7930
7931
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 1520 times.
1824 if(arrow==-1)
7932 {
7933 1520 return;
7934 }
7935
7936 304 zfix x = (Lwpns.spr(arrow)->x-3)+(zc_oldrand()%7);
7937 304 zfix y = (Lwpns.spr(arrow)->y-3)+(zc_oldrand()%7)-Lwpns.spr(arrow)->fakez;
7938
6/12
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 304 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 304 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 304 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 304 times.
✗ Branch 11 not taken.
304 Lwpns.add(new weapon(x, y, Lwpns.spr(arrow)->z, wPhantom, type2,0,0,((weapon*)Lwpns.spr(arrow))->parentitem,-1));
7939 7410 }
7940
7941 //cleans up decorations that exit the bounds of the screen for a int32_t time, to prevebt them wrapping around.
7942 14168556 void HeroClass::PhantomsCleanup()
7943 {
7944
2/2
✓ Branch 0 taken 14167322 times.
✓ Branch 1 taken 1234 times.
14168556 if(Lwpns.idCount(wPhantom))
7945 {
7946
2/2
✓ Branch 0 taken 8023 times.
✓ Branch 1 taken 1234 times.
9257 for(int32_t i=0; i<Lwpns.Count(); i++)
7947 {
7948 8023 weapon *w = ((weapon *)Lwpns.spr(i));
7949
3/4
✓ Branch 0 taken 4869 times.
✓ Branch 1 taken 3154 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4869 times.
8023 if ( w->id == wPhantom && !w->isScriptGenerated() )
7950 {
7951
4/8
✓ Branch 0 taken 4869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4869 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4869 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4869 times.
4869 if ( w->x < -10000 || w->y > 10000 || w->x < -10000 || w->y > 10000 )
7952 {
7953 Lwpns.remove(w);
7954 }
7955 4869 }
7956 8023 }
7957 1234 }
7958 14168556 }
7959
7960 //Waitframe handler for refilling operations
7961 6288 static void do_refill_waitframe()
7962 {
7963 6288 put_passive_subscr(framebuf,0,passive_subscreen_offset,game->should_show_time(),sspUP);
7964
1/2
✓ Branch 0 taken 6288 times.
✗ Branch 1 not taken.
6288 if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
7965 {
7966 script_drawing_commands.Clear();
7967 if(DMaps[currdmap].passive_sub_script != 0)
7968 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
7969
7970 if (FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && DMaps[currdmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen))
7971 {
7972 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
7973 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
7974 }
7975 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
7976 }
7977 6288 advanceframe(true);
7978 6288 }
7979 //Special handler if it's a "fairy revive"
7980 static void do_death_refill_waitframe()
7981 {
7982 //!TODO Run a new script slot each frame here, before calling do_refill_waitframe()
7983 //This script should be able to draw a 'fairy saving the player' animation -Em
7984 do_refill_waitframe();
7985 }
7986
7987 1 static size_t find_bottle_for_slot(size_t slot, bool unowned=false)
7988 {
7989 1 int32_t found_unowned = -1;
7990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153 times.
153 for(int q = 0; q < MAXITEMS; ++q)
7991 {
7992
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 152 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
153 if(itemsbuf[q].family == itype_bottle && itemsbuf[q].misc1 == slot)
7993 {
7994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(game->get_item(q))
7995 1 return q;
7996 if(unowned)
7997 found_unowned = q;
7998 }
7999 152 }
8000 return found_unowned;
8001 1 }
8002
8003 int32_t getPushDir(int32_t flag)
8004 {
8005 switch(flag)
8006 {
8007 case mfPUSHUD: case mfPUSH4: case mfPUSHU: case mfPUSHUDNS:
8008 case mfPUSH4NS: case mfPUSHUNS: case mfPUSHUDINS: case mfPUSH4INS:
8009 case mfPUSHUINS:
8010 return up;
8011 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8012 return down;
8013 case mfPUSHLR: case mfPUSHL: case mfPUSHLRNS: case mfPUSHLNS:
8014 case mfPUSHLRINS: case mfPUSHLINS:
8015 return left;
8016 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8017 return right;
8018 }
8019 return -1;
8020 }
8021
8022 void post_item_collect();
8023
8024 14170185 bool HeroClass::handle_portal_collide(portal* p)
8025 {
8026
1/2
✓ Branch 0 taken 14170185 times.
✗ Branch 1 not taken.
14170185 if(!p) return false;
8027 14170185 p->animate(0);
8028
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14170185 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14170185 if(p->destdmap < 0 || p->destdmap >= MAXDMAPS)
8029 14170185 return false;
8030 if(abs(x - p->x) < 12
8031 && abs(y - p->y) < 12)
8032 {
8033 if(p->prox_active)
8034 {
8035 //Store some values to restore if 'warp fails'
8036 int32_t tLastEntrance = lastentrance,
8037 tLastEntranceDMap = lastentrance_dmap,
8038 tContScr = game->get_continue_scrn(),
8039 tContDMap = game->get_continue_dmap();
8040 int32_t sourcescr = currscr, sourcedmap = currdmap;
8041 zfix tx = x, ty = y, tz = z;
8042 x = p->x;
8043 y = p->y;
8044
8045 int32_t weff = p->weffect,
8046 wsfx = p->wsfx;
8047
8048 int32_t savep = p->saved_data;
8049 //After this line, 'p' becomes INVALID!
8050 FFCore.warp_player(wtIWARP, p->destdmap, p->destscr,
8051 -1, -1, weff, wsfx, 0, -1);
8052
8053 if(mirrorBonk()) //Invalid landing, warp back!
8054 {
8055 action = none; FFCore.setHeroAction(none);
8056 lastentrance = tLastEntrance;
8057 lastentrance_dmap = tLastEntranceDMap;
8058 game->set_continue_scrn(tContScr);
8059 game->set_continue_dmap(tContDMap);
8060 x = tx;
8061 y = ty;
8062 z = tz;
8063 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, weff,
8064 wsfx, 0, -1);
8065 handle_portal_prox(&mirror_portal);
8066 portals.forEach([&](sprite& p)
8067 {
8068 handle_portal_prox((portal*)&p);
8069 return false;
8070 });
8071 }
8072 else game->clear_portal(savep); //Remove portal once used
8073 return true;
8074 }
8075 }
8076 else p->prox_active = true;
8077 return false;
8078 14170185 }
8079 147 void HeroClass::handle_portal_prox(portal* p)
8080 {
8081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(!p) return;
8082
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 23 times.
147 p->prox_active = !(abs(x - p->x) < 12 && abs(y - p->y) < 12);
8083 147 }
8084 // returns true when game over
8085 41887793 bool HeroClass::animate(int32_t)
8086 {
8087 41887793 int32_t lsave=0;
8088
1/2
✓ Branch 0 taken 41887793 times.
✗ Branch 1 not taken.
41887793 if(immortal > 0)
8089 --immortal;
8090 41887793 prompt_combo = 0;
8091
2/2
✓ Branch 0 taken 27718231 times.
✓ Branch 1 taken 14169562 times.
41887793 if (onpassivedmg)
8092 {
8093 27718231 onpassivedmg=false;
8094 27718231 }
8095
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 14169557 times.
14169562 else if (damageovertimeclk)
8096 {
8097 5 damageovertimeclk = 0;
8098 5 }
8099
8100
2/2
✓ Branch 0 taken 41876728 times.
✓ Branch 1 taken 11065 times.
41887793 if(lift_wpn)
8101 {
8102 11065 auto oldid = lift_wpn->id;
8103
2/2
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 10142 times.
11065 switch(lift_wpn->id)
8104 {
8105 case wLitBomb:
8106 case wBomb:
8107 case wLitSBomb:
8108 case wSBomb:
8109
2/4
✓ Branch 0 taken 923 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 923 times.
923 if(lift_wpn->misc && get_qr(qr_HELD_BOMBS_EXPLODE)) //timed fuse
8110 {
8111 923 lift_wpn->limited_animate();
8112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 923 times.
923 if(lift_wpn->id != oldid)
8113 {
8114 lift_wpn->moveflags &= ~move_obeys_grav;
8115 drop_liftwpn();
8116 goto heroanimate_skip_liftwpn;
8117 }
8118 923 ++lift_wpn->clk;
8119 923 }
8120 923 break;
8121 }
8122
1/2
✓ Branch 0 taken 11065 times.
✗ Branch 1 not taken.
11065 if(lift_wpn->dead>0)
8123 --lift_wpn->dead;
8124
8125
1/2
✓ Branch 0 taken 11065 times.
✗ Branch 1 not taken.
11065 if(lift_wpn->dead==0)
8126 {
8127 if(lift_wpn->death_spawnitem > -1)
8128 {
8129 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, lift_wpn->death_spawnitem, lift_wpn->death_item_pflags, 0));
8130 itm->fakez = lift_wpn->fakez;
8131 items.add(itm);
8132 }
8133 if(lift_wpn->death_spawndropset > -1)
8134 {
8135 auto itid = select_dropitem(lift_wpn->death_spawndropset);
8136 if(itid > -1)
8137 {
8138 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, itid, lift_wpn->death_item_pflags, 0));
8139 itm->fakez = lift_wpn->fakez;
8140 itm->from_dropset = lift_wpn->death_spawndropset;
8141 items.add(itm);
8142 }
8143 }
8144 switch(lift_wpn->death_sprite)
8145 {
8146 case -2: decorations.add(new dBushLeaves(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dBUSHLEAVES, 0, 0)); break;
8147 case -3: decorations.add(new dFlowerClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dFLOWERCLIPPINGS, 0, 0)); break;
8148 case -4: decorations.add(new dGrassClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dGRASSCLIPPINGS, 0, 0)); break;
8149 default:
8150 if(lift_wpn->death_sprite < 0) break;
8151 decorations.add(new comboSprite(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dCOMBOSPRITE, 0, lift_wpn->death_sprite));
8152 }
8153 if(lift_wpn->death_sfx > 0)
8154 sfx(lift_wpn->death_sfx, pan(int32_t(lift_wpn->x)));
8155 delete lift_wpn;
8156 lift_wpn = nullptr;
8157 }
8158 heroanimate_skip_liftwpn:;
8159 11065 }
8160
8161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41887793 times.
41887793 if(cheats_execute_goto)
8162 {
8163 didpit=true;
8164 pitx=x;
8165 pity=y;
8166 dowarp(3,0);
8167 cheats_execute_goto=false;
8168 solid_update(false);
8169 return false;
8170 }
8171
8172
1/2
✓ Branch 0 taken 41887793 times.
✗ Branch 1 not taken.
41887793 if(cheats_execute_light)
8173 {
8174 toggle_lights(pal_litOVERRIDE); //Forcibly set permLit, overriding its current setting
8175 cheats_execute_light = false;
8176 }
8177
8178
3/4
✓ Branch 0 taken 14170185 times.
✓ Branch 1 taken 27717608 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14170185 times.
41887793 if(action!=climbcovertop&&action!=climbcoverbottom)
8179 {
8180 14170185 climb_cover_x=-1000;
8181 14170185 climb_cover_y=-1000;
8182 14170185 }
8183
8184 41887793 handle_portal_collide(&mirror_portal);
8185
1/2
✓ Branch 0 taken 41887793 times.
✗ Branch 1 not taken.
41887793 portals.forEach([&](sprite& p)
8186 {
8187 return handle_portal_collide((portal*)&p);
8188 });
8189
8190
3/4
✓ Branch 0 taken 14153730 times.
✓ Branch 1 taken 27734063 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14153730 times.
41887793 if(z<=8&&fakez<=8) //Tall Grass
8191 {
8192 14153730 int maxlyr = get_qr(qr_BUSHESONLAYERS1AND2) ? 2 : 0;
8193
2/2
✓ Branch 0 taken 632883 times.
✓ Branch 1 taken 13520847 times.
14153730 if (get_qr(qr_GRASS_SENSITIVE))
8194 {
8195 632883 bool g1 = false, g2 = false, g3 = false, g4 = false;
8196
2/2
✓ Branch 0 taken 1815587 times.
✓ Branch 1 taken 632883 times.
2448470 for(int q = maxlyr; q >= 0; --q)
8197 {
8198
2/2
✓ Branch 0 taken 2282 times.
✓ Branch 1 taken 1813305 times.
1815587 g1 = g1 || isGrassType(combobuf[MAPCOMBO2(q-1,x+4,y+15)].type);
8199
2/2
✓ Branch 0 taken 2251 times.
✓ Branch 1 taken 1813336 times.
1815587 g2 = g2 || isGrassType(combobuf[MAPCOMBO2(q-1,x+11,y+15)].type);
8200
2/2
✓ Branch 0 taken 2323 times.
✓ Branch 1 taken 1813264 times.
1815587 g3 = g3 || isGrassType(combobuf[MAPCOMBO2(q-1,x+4,y+9)].type);
8201
2/2
✓ Branch 0 taken 2350 times.
✓ Branch 1 taken 1813237 times.
1815587 g4 = g4 || isGrassType(combobuf[MAPCOMBO2(q-1,x+11,y+9)].type);
8202 1815587 }
8203
8/8
✓ Branch 0 taken 8260 times.
✓ Branch 1 taken 624623 times.
✓ Branch 2 taken 7135 times.
✓ Branch 3 taken 1125 times.
✓ Branch 4 taken 6227 times.
✓ Branch 5 taken 908 times.
✓ Branch 6 taken 62 times.
✓ Branch 7 taken 6165 times.
632883 if(g1 && g2 && g3 && g4)
8204 {
8205 6165 int grasscid = 0;
8206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16508 times.
16508 for(int q = maxlyr; q >= 0; --q)
8207 {
8208 16508 int cid = MAPCOMBO2(q-1,x+8,y+12);
8209
4/4
✓ Branch 0 taken 7637 times.
✓ Branch 1 taken 8871 times.
✓ Branch 2 taken 1472 times.
✓ Branch 3 taken 6165 times.
16508 if(cid > 0 && isGrassType(combobuf[cid].type))
8210 {
8211 6165 grasscid = cid;
8212 6165 break;
8213 }
8214 10343 }
8215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6165 times.
6165 if(grasscid)
8216 {
8217 6165 newcombo const& cmb = combobuf[grasscid];
8218
2/2
✓ Branch 0 taken 5003 times.
✓ Branch 1 taken 1162 times.
6165 if(decorations.idCount(dTALLGRASS)==0)
8219 {
8220
3/6
✓ Branch 0 taken 1162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
1162 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0, cmb.attribytes[6]));
8221 1162 }
8222 6165 int32_t thesfx = cmb.attribytes[3];
8223
2/2
✓ Branch 0 taken 2035 times.
✓ Branch 1 taken 4130 times.
6165 if (action==walking)
8224 4130 sfx_no_repeat(thesfx,pan((int32_t)x));
8225 6165 }
8226 6165 }
8227 632883 }
8228 else
8229 {
8230 13520847 bool g1 = false, g2 = false;
8231
2/2
✓ Branch 0 taken 13819799 times.
✓ Branch 1 taken 13520847 times.
27340646 for(int q = maxlyr; q >= 0; --q)
8232 {
8233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13819799 times.
13819799 g1 = g1 || isGrassType(combobuf[MAPCOMBO2(q-1,x,y+15)].type);
8234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13819799 times.
13819799 g2 = g2 || isGrassType(combobuf[MAPCOMBO2(q-1,x+15,y+15)].type);
8235 13819799 }
8236
4/4
✓ Branch 0 taken 135558 times.
✓ Branch 1 taken 13385289 times.
✓ Branch 2 taken 30116 times.
✓ Branch 3 taken 105442 times.
13520847 if(g1 && g2)
8237 {
8238 105442 int grasscid = 0;
8239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108736 times.
108736 for(int q = maxlyr; q >= 0; --q)
8240 {
8241 108736 int cid = MAPCOMBO2(q-1,x+8,y+15);
8242
3/4
✓ Branch 0 taken 105442 times.
✓ Branch 1 taken 3294 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105442 times.
108736 if(cid > 0 && isGrassType(combobuf[cid].type))
8243 {
8244 105442 grasscid = cid;
8245 105442 break;
8246 }
8247 3294 }
8248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105442 times.
105442 if(grasscid)
8249 {
8250 105442 newcombo const& cmb = combobuf[grasscid];
8251
2/2
✓ Branch 0 taken 102833 times.
✓ Branch 1 taken 2609 times.
105442 if(decorations.idCount(dTALLGRASS)==0)
8252 {
8253
3/6
✓ Branch 0 taken 2609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2609 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2609 times.
✗ Branch 5 not taken.
2609 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0, cmb.attribytes[6]));
8254 2609 }
8255 105442 int32_t thesfx = cmb.attribytes[3];
8256
2/2
✓ Branch 0 taken 38255 times.
✓ Branch 1 taken 67187 times.
105442 if (action==walking )
8257 67187 sfx_no_repeat(thesfx,pan((int32_t)x));
8258 105442 }
8259 105442 }
8260 }
8261 14153730 }
8262
3/4
✓ Branch 0 taken 14151529 times.
✓ Branch 1 taken 27736264 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14151529 times.
41887793 if(z==0 && fakez==0) //Shallow Water / Custom Walk SFX
8263 {
8264
2/2
✓ Branch 0 taken 1124546 times.
✓ Branch 1 taken 13026983 times.
14151529 if (get_qr(qr_SHALLOW_SENSITIVE))
8265 {
8266
18/22
✓ Branch 0 taken 1116491 times.
✓ Branch 1 taken 8055 times.
✓ Branch 2 taken 1116491 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1112235 times.
✓ Branch 5 taken 4256 times.
✓ Branch 6 taken 1111979 times.
✓ Branch 7 taken 256 times.
✓ Branch 8 taken 1111979 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1111979 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1108199 times.
✓ Branch 13 taken 3780 times.
✓ Branch 14 taken 1108199 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1108166 times.
✓ Branch 17 taken 33 times.
✓ Branch 18 taken 1097755 times.
✓ Branch 19 taken 10411 times.
✓ Branch 20 taken 1288 times.
✓ Branch 21 taken 1096467 times.
1124546 if (action != swimming && action != isdiving && action != drowning && action!=lavadrowning && action!=sidedrowning && action!=rafting && action != falling && !IsSideSwim() && !(ladderx+laddery) && !pull_hero && !toogam)
8267 {
8268
2/2
✓ Branch 0 taken 1043659 times.
✓ Branch 1 taken 52808 times.
1157022 if (iswaterex(FFORCOMBO(x+11,y+15), currmap, currscr, -1, x+11,y+15, false, false, true, true)
8269
2/2
✓ Branch 0 taken 60555 times.
✓ Branch 1 taken 1035912 times.
1096467 && iswaterex(FFORCOMBO(x+4,y+15), currmap, currscr, -1, x+4,y+15, false, false, true, true)
8270
2/2
✓ Branch 0 taken 56317 times.
✓ Branch 1 taken 4238 times.
60555 && iswaterex(FFORCOMBO(x+11,y+9), currmap, currscr, -1, x+11,y+9, false, false, true, true)
8271
2/2
✓ Branch 0 taken 3363 times.
✓ Branch 1 taken 52954 times.
56317 && iswaterex(FFORCOMBO(x+4,y+9), currmap, currscr, -1, x+4,y+9, false, false, true, true))
8272 {
8273 52808 int watercheck_x = x.getInt()+7.5, watercheck_y = y.getInt()+12;
8274 52808 int ffpos = getFFCAt(watercheck_x,watercheck_y);
8275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52808 times.
52808 int combopos = ffpos < 0 ? COMBOPOS(watercheck_x,watercheck_y) : -1;
8276
4/8
✓ Branch 0 taken 52808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52808 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52808 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 52808 times.
52808 if(watercheck_x < 0 || watercheck_x > 255 || watercheck_y < 0 || watercheck_y > 175)
8277 combopos = -1;
8278
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52808 times.
✓ Branch 2 taken 52808 times.
✗ Branch 3 not taken.
52808 int waterid = ffpos > -1 ? tmpscr->ffcs[ffpos].data : (combopos > -1 ? tmpscr->data[combopos] : 0);
8279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52808 times.
52808 if(waterid)
8280 52808 waterid = iswaterex(waterid, currmap, currscr, -1, watercheck_x,watercheck_y, false, false, true, true);
8281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52808 times.
52808 if(waterid)
8282 {
8283 52808 newcombo const& watercmb = combobuf[waterid];
8284 52808 auto ripplesprite = watercmb.attribytes[6];
8285
2/2
✓ Branch 0 taken 52361 times.
✓ Branch 1 taken 447 times.
52808 if(decorations.idCount(dRIPPLES)==0)
8286
3/6
✓ Branch 0 taken 447 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 447 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 447 times.
✗ Branch 5 not taken.
447 decorations.add(new dRipples(x, y, dRIPPLES, 0, ripplesprite));
8287
2/2
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 52185 times.
52808 if (watercmb.usrflags&cflag2)
8288 {
8289
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
623 if (!(current_item(watercmb.attribytes[2]) > 0 && current_item(watercmb.attribytes[2]) >= watercmb.attribytes[3]))
8290 {
8291 623 onpassivedmg = true;
8292
2/2
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 314 times.
623 if (!damageovertimeclk)
8293 {
8294 314 int32_t curhp = game->get_life();
8295 314 auto dmg = watercmb.attributes[1]/10000L;
8296 314 auto hitsfx = watercmb.attributes[2]/10000L;
8297
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 bool hitstun = dmg < 0 && (watercmb.usrflags&cflag7);
8298
8299
2/4
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 314 times.
314 if(game->get_life() == curhp && (watercmb.usrflags&cflag6))
8300 314 hitsfx = 0;
8301
8302 314 std::vector<int32_t> &ev = FFCore.eventData;
8303 314 ev.clear();
8304 314 ev.push_back(-dmg*10000);
8305 314 ev.push_back(-1*10000);
8306 314 ev.push_back(0);
8307 314 ev.push_back(0);
8308 314 ev.push_back(48*10000);
8309 314 ev.push_back(ZSD_COMBODATA*10000);
8310 314 ev.push_back(waterid);
8311 314 ev.push_back((ffpos > -1 ? ZSD_FFC : ZSD_COMBOPOS)*10000);
8312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 314 times.
314 ev.push_back(ffpos > -1 ? ffpos : combopos*10000);
8313
8314 314 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
8315
8316
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(watercmb.usrflags & cflag5)
8317 ev[0] = ringpower(ev[0]/10000) * 10000;
8318
8319 314 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
8320 314 dmg = -ev[0]/10000;
8321
8322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 314 times.
314 if(!ev[2]) //nullify
8323 {
8324 314 game->set_life(vbound(game->get_life()+dmg, 0, game->get_maxlife()));
8325
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if (hitsfx)
8326 sfx(hitsfx);
8327
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if (hitstun)
8328 {
8329 hclk = ev[4]/10000;
8330 hitdir = ev[1]/10000;
8331 action = gothit; FFCore.setHeroAction(gothit);
8332 }
8333 314 }
8334 314 }
8335
1/2
✓ Branch 0 taken 623 times.
✗ Branch 1 not taken.
623 if (watercmb.attribytes[1] > 0)
8336 {
8337
3/4
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 314 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 309 times.
623 if (!damageovertimeclk || damageovertimeclk > watercmb.attribytes[1]) damageovertimeclk = watercmb.attribytes[1];
8338 309 else --damageovertimeclk;
8339 623 }
8340 else damageovertimeclk = 0;
8341 623 }
8342 else damageovertimeclk = 0;
8343 623 }
8344 52185 else damageovertimeclk = 0;
8345 52808 int32_t thesfx = watercmb.attribytes[0];
8346
4/4
✓ Branch 0 taken 51858 times.
✓ Branch 1 taken 950 times.
✓ Branch 2 taken 46233 times.
✓ Branch 3 taken 5625 times.
52808 if (watercmb.type != cSHALLOWWATER || !get_qr(qr_OLD_SHALLOW_SFX))
8347 {
8348 6575 thesfx = watercmb.attribytes[5];
8349 6575 }
8350
2/2
✓ Branch 0 taken 28715 times.
✓ Branch 1 taken 24093 times.
52808 if (action==walking)
8351 24093 sfx_no_repeat(thesfx,pan((int32_t)x));
8352 52808 }
8353 52808 }
8354 1096467 }
8355 1124546 }
8356 else
8357 {
8358
4/4
✓ Branch 0 taken 12871554 times.
✓ Branch 1 taken 155429 times.
✓ Branch 2 taken 12884792 times.
✓ Branch 3 taken 142191 times.
13026983 if((COMBOTYPE(x,y+15)==cSHALLOWWATER)&&(COMBOTYPE(x+15,y+15)==cSHALLOWWATER))
8359 {
8360 142191 int32_t watercheck = FFORCOMBO(x+7.5,y.getInt()+15);
8361 142191 auto ripplesprite = combobuf[watercheck].attribytes[6];
8362
2/2
✓ Branch 0 taken 140789 times.
✓ Branch 1 taken 1402 times.
142191 if(decorations.idCount(dRIPPLES)==0)
8363 {
8364
3/6
✓ Branch 0 taken 1402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1402 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1402 times.
✗ Branch 5 not taken.
1402 decorations.add(new dRipples(x, y, dRIPPLES, 0, ripplesprite));
8365 1402 }
8366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142191 times.
142191 if (combobuf[watercheck].usrflags&cflag2)
8367 {
8368 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
8369 {
8370 onpassivedmg = true;
8371 if (!damageovertimeclk)
8372 {
8373 int32_t curhp = game->get_life();
8374 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
8375 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
8376 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
8377 }
8378 if (combobuf[watercheck].attribytes[1] > 0)
8379 {
8380 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
8381 else --damageovertimeclk;
8382 }
8383 else damageovertimeclk = 0;
8384 }
8385 else damageovertimeclk = 0;
8386 }
8387 142191 else damageovertimeclk = 0;
8388 142191 int32_t thesfx = combobuf[watercheck].attribytes[0];
8389
2/2
✓ Branch 0 taken 53383 times.
✓ Branch 1 taken 88808 times.
142191 if (action==walking )
8390 88808 sfx_no_repeat(thesfx,pan((int32_t)x));
8391 142191 }
8392 }
8393
8394 14151529 auto cpos = COMBOPOS(x+8,y+(sideview_mode()?16:12));
8395
2/2
✓ Branch 0 taken 99060703 times.
✓ Branch 1 taken 14151529 times.
113212232 for(int q = 0; q < 7; ++q)
8396 {
8397 99060703 mapscr* lyr = FFCore.tempScreens[q];
8398 99060703 auto cid = lyr->data[cpos];
8399 99060703 newcombo const& cmb = combobuf[cid];
8400
2/2
✓ Branch 0 taken 52594227 times.
✓ Branch 1 taken 46466476 times.
99060703 byte csfx = action == walking ? cmb.sfx_walking : cmb.sfx_standing;
8401
2/2
✓ Branch 0 taken 52594227 times.
✓ Branch 1 taken 46466476 times.
99060703 byte cspr = action == walking ? cmb.spr_walking : cmb.spr_standing;
8402
2/2
✓ Branch 0 taken 9624 times.
✓ Branch 1 taken 99051079 times.
99060703 if(csfx)
8403 9624 sfx_no_repeat(csfx);
8404 99060703 auto indx = decorations.idFirst(dCUSTOMWALK);
8405
1/2
✓ Branch 0 taken 99060703 times.
✗ Branch 1 not taken.
99060703 if(cspr)
8406 {
8407 if(indx < 0)
8408 {
8409 if(decorations.add(new customWalkSprite(x, y, dCUSTOMWALK, 0, -1)))
8410 indx = decorations.Count()-1;
8411 }
8412 if(indx > -1)
8413 {
8414 if(customWalkSprite* spr = dynamic_cast<customWalkSprite*>(decorations.spr(indx)))
8415 spr->run_sprite(cspr);
8416 }
8417 }
8418 99060703 }
8419 14151529 }
8420
8421
2/2
✓ Branch 0 taken 41887372 times.
✓ Branch 1 taken 421 times.
41887793 if(stomping)
8422 421 stomping = false;
8423
8424
1/2
✓ Branch 0 taken 41887793 times.
✗ Branch 1 not taken.
41887793 if(getOnSideviewLadder())
8425 {
8426 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
8427 {
8428 setOnSideviewLadder(false);
8429 }
8430 else if(CANFORCEFACEUP)
8431 {
8432 setDir(up);
8433 }
8434 }
8435
8436
7/8
✓ Branch 0 taken 14153703 times.
✓ Branch 1 taken 27734090 times.
✓ Branch 2 taken 14147719 times.
✓ Branch 3 taken 5984 times.
✓ Branch 4 taken 14147463 times.
✓ Branch 5 taken 256 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 14147463 times.
41887793 if(action!=inwind && action!=drowning && action!=lavadrowning && action!= sidedrowning)
8437 {
8438
2/2
✓ Branch 0 taken 13146005 times.
✓ Branch 1 taken 1001458 times.
14147463 if(!get_qr(qr_OLD_CHEST_COLLISION))
8439 {
8440 1001458 checkchest(cCHEST);
8441 1001458 checkchest(cLOCKEDCHEST);
8442 1001458 checkchest(cBOSSCHEST);
8443 1001458 }
8444
2/2
✓ Branch 0 taken 13582672 times.
✓ Branch 1 taken 564791 times.
14147463 if(!get_qr(qr_OLD_LOCKBLOCK_COLLISION))
8445 {
8446 564791 checkchest(cLOCKBLOCK);
8447 564791 checkchest(cBOSSLOCKBLOCK);
8448 564791 }
8449 14147463 }
8450 41887793 checksigns();
8451 41887793 checkgenpush();
8452
8453
4/4
✓ Branch 0 taken 13424429 times.
✓ Branch 1 taken 28463364 times.
✓ Branch 2 taken 2628 times.
✓ Branch 3 taken 13421801 times.
41887793 if(isStanding(true) && fall == 0)
8454 {
8455
1/2
✓ Branch 0 taken 13421801 times.
✗ Branch 1 not taken.
13421801 if(extra_jump_count > 0)
8456 extra_jump_count = 0;
8457 13421801 coyotetime = 0;
8458 13421801 }
8459
2/2
✓ Branch 0 taken 27733817 times.
✓ Branch 1 taken 732175 times.
28465992 else if(coyotetime < 65535)
8460 {
8461 732175 ++coyotetime;
8462 732175 }
8463
2/2
✓ Branch 0 taken 41879504 times.
✓ Branch 1 taken 8289 times.
41887793 if(can_use_item(itype_hoverboots,i_hoverboots))
8464 {
8465 8289 int32_t hoverid = current_item_id(itype_hoverboots);
8466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8289 times.
8289 if(!(itemsbuf[hoverid].flags & item_flag1))
8467 {
8468
1/2
✓ Branch 0 taken 8289 times.
✗ Branch 1 not taken.
8289 if(hoverclk < 0) hoverclk = 0;
8469 8289 hoverflags &= ~HOV_OUT;
8470 8289 }
8471 8289 }
8472 41887793 bool platformfell2 = false;
8473 41887793 int32_t gravity3 = (zinit.gravity/100);
8474 41887793 int32_t termv = (zinit.terminalv);
8475 41887793 int32_t rocs = getRocsPressed();
8476
2/2
✓ Branch 0 taken 41881733 times.
✓ Branch 1 taken 6060 times.
41887793 if (rocs != -1)
8477 {
8478 6060 itemdata const& itm = itemsbuf[rocs];
8479
1/2
✓ Branch 0 taken 6060 times.
✗ Branch 1 not taken.
6060 if (itm.flags & item_flag2)
8480 {
8481 if ((!(itm.flags & item_flag3) || fall < 0) &&
8482 (!(itm.flags & item_flag4) || fall > 0)) gravity3 = itm.misc3;
8483 }
8484
1/2
✓ Branch 0 taken 6060 times.
✗ Branch 1 not taken.
6060 if (itm.flags & item_flag5)
8485 {
8486 termv = itm.misc4;
8487 if (fall > termv) fall = termv;
8488 }
8489 6060 }
8490
2/2
✓ Branch 0 taken 255625 times.
✓ Branch 1 taken 41632168 times.
41887793 if(sideview_mode()) // Sideview gravity
8491 {
8492 //Handle falling through a platform
8493 255625 bool platformfell = false;
8494
3/4
✓ Branch 0 taken 128755 times.
✓ Branch 1 taken 126870 times.
✓ Branch 2 taken 128755 times.
✗ Branch 3 not taken.
255625 if (on_sideview_solid_oldpos(this,true,3) && !on_sideview_solid_oldpos(this,false,3))
8495 {
8496 if (!(!on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && Down())) platformfell = true;
8497 y+=1; //Fall down a pixel instantly, through the platform.
8498 if(fall < 0) fall = 0;
8499 if(jumping < 0) jumping = 0;
8500 platformfell2 = true;
8501 }
8502 //Unless using old collision, run this check BEFORE moving Hero, to prevent clipping into the ceiling.
8503
2/2
✓ Branch 0 taken 250696 times.
✓ Branch 1 taken 4929 times.
255625 if(!get_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON))
8504 {
8505
14/22
✓ Branch 0 taken 3996 times.
✓ Branch 1 taken 933 times.
✓ Branch 2 taken 933 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 933 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 933 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 933 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 921 times.
✓ Branch 12 taken 921 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 921 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 921 times.
✓ Branch 18 taken 921 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 4917 times.
✓ Branch 21 taken 12 times.
5862 if(fall < 0 && (_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE)
8506
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 921 times.
✓ Branch 2 taken 921 times.
✗ Branch 3 not taken.
921 || ((y+(fall/100)<=0) &&
8507 // Extra checks if Smart Screen Scrolling is enabled
8508 (nextcombo_wf(up) || ((get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8509 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up)))))))
8510 {
8511 12 fall = jumping = 0; // Bumped his head
8512
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
8513 y -= y.getInt()%8; //fix coords
8514 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if ( !get_qr(qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8516 {
8517 12 checkdamagecombos(x+4, x+12, y-1, y-1);
8518 12 }
8519 12 }
8520 4929 }
8521 // Fall, unless on a ladder, sideview ladder, rafting, using the hookshot, drowning, sideswimming or cheating.
8522
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 255625 times.
✓ Branch 2 taken 255625 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 255625 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 255625 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 255625 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 255625 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 255625 times.
255625 if(!(toogam && Up()) && !drownclk && action!=rafting && !IsSideSwim() && !pull_hero && !((ladderx || laddery) && fall>0) && !getOnSideviewLadder())
8523 {
8524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255625 times.
255625 int32_t ydiff = fall/(spins && fall<0 ? 200:100);
8525 255625 falling_oldy = y; // Stomp Boots-related variable
8526
5/8
✓ Branch 0 taken 48242 times.
✓ Branch 1 taken 207383 times.
✓ Branch 2 taken 48242 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48242 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 255625 times.
✗ Branch 7 not taken.
255625 if(fall > 0 && (checkSVLadderPlatform(x+4,y+ydiff+15)||checkSVLadderPlatform(x+12,y+ydiff+15)) && (((y.getInt()+ydiff+15)&0xF0)!=((y.getInt()+15)&0xF0)) && !platform_fallthrough())
8527 {
8528 ydiff -= (y.getInt()+ydiff)%16;
8529 }
8530
4/4
✓ Branch 0 taken 68669 times.
✓ Branch 1 taken 186956 times.
✓ Branch 2 taken 66794 times.
✓ Branch 3 taken 1875 times.
255625 if(ydiff && !get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
8531 {
8532
2/2
✓ Branch 0 taken 1071 times.
✓ Branch 1 taken 804 times.
1875 if(ydiff > 0)
8533 {
8534
2/2
✓ Branch 0 taken 1026 times.
✓ Branch 1 taken 2196 times.
3222 for(auto q = 0; q < ydiff; ++q)
8535 {
8536
2/2
✓ Branch 0 taken 2151 times.
✓ Branch 1 taken 45 times.
2196 if(on_sideview_solid_oldpos(this, false, 0, 0, q))
8537 {
8538 45 ydiff = q;
8539 45 break;
8540 }
8541 2151 }
8542 1071 }
8543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 else if(ydiff < 0)
8544 {
8545
2/2
✓ Branch 0 taken 804 times.
✓ Branch 1 taken 1644 times.
2448 for(auto q = 0; q > ydiff; --q)
8546 {
8547
1/2
✓ Branch 0 taken 1644 times.
✗ Branch 1 not taken.
1644 if(_walkflag(x+4,y+(bigHitbox?0:8)+q-1,1)
8548
1/2
✓ Branch 0 taken 1644 times.
✗ Branch 1 not taken.
1644 || _walkflag(x+12,y+(bigHitbox?0:8)+q,1))
8549 {
8550 ydiff = q;
8551 break;
8552 }
8553 1644 }
8554 804 }
8555 1875 }
8556 255625 y+=ydiff;
8557 255625 hs_starty+=ydiff;
8558
8559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255625 times.
255625 for(int32_t j=0; j<chainlinks.Count(); j++)
8560 {
8561 chainlinks.spr(j)->y+=ydiff;
8562 }
8563
8564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255625 times.
255625 if(Lwpns.idFirst(wHookshot)>-1)
8565 {
8566 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=ydiff;
8567 }
8568
8569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255625 times.
255625 if(Lwpns.idFirst(wHSHandle)>-1)
8570 {
8571 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=ydiff;
8572 }
8573 255625 }
8574 else if(IsSideSwim() && action != sidewaterhold1 && action != sidewaterhold2 && action != sideswimcasting && action != sideswimfreeze)
8575 {
8576 fall = hoverclk = jumping = 0;
8577 inair = false;
8578 hoverflags = 0;
8579 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
8580 {
8581 WalkflagInfo info;
8582 if (game->get_watergrav()<0)
8583 {
8584 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
8585 execute(info);
8586 }
8587 else
8588 {
8589 info = walkflag(x,y+15+2,2,down);
8590 execute(info);
8591 }
8592 if(!info.isUnwalkable() && (game->get_watergrav() > 0 || iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)-2), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false))) y+=(game->get_watergrav()/10000.0);
8593 }
8594 }
8595 // Stop hovering/falling if you land on something.
8596 255625 bool needFall = false;
8597
6/8
✓ Branch 0 taken 126382 times.
✓ Branch 1 taken 129243 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 255625 times.
✓ Branch 4 taken 129243 times.
✓ Branch 5 taken 126382 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 129243 times.
255625 if((on_sideview_solid_oldpos(this) || getOnSideviewLadder()) && !(pull_hero && dir==down) && action!=rafting && !platformfell2)
8598 {
8599 129243 stop_item_sfx(itype_hoverboots);
8600
2/2
✓ Branch 0 taken 126660 times.
✓ Branch 1 taken 2583 times.
129243 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
8601 {
8602
4/6
✓ Branch 0 taken 126660 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124016 times.
✓ Branch 3 taken 2644 times.
✓ Branch 4 taken 124016 times.
✗ Branch 5 not taken.
126660 if(!getOnSideviewLadder() && (fall > 0 || get_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON)))
8603 {
8604 126660 y.doFloor();
8605 126660 y-=(int32_t)y%8; //fix position
8606 126660 }
8607 126660 }
8608 else
8609 {
8610 2583 snap_platform();
8611 }
8612 129243 fall = hoverclk = jumping = 0;
8613 129243 inair = false;
8614 129243 hoverflags = 0;
8615
8616
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 129235 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
129243 if(y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) // Landed on the bottommost screen.
8617 8 y = 160;
8618 129243 }
8619 // Stop hovering if you press down.
8620
3/6
✓ Branch 0 taken 126382 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126382 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126382 times.
✗ Branch 5 not taken.
126382 else if((hoverclk>0 || ladderx || laddery) && DrunkDown())
8621 {
8622 stop_item_sfx(itype_hoverboots);
8623 hoverclk = -hoverclk;
8624 reset_ladder();
8625 fall = gravity3;
8626 inair = false;
8627 }
8628
8/10
✓ Branch 0 taken 126382 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2945 times.
✓ Branch 3 taken 123437 times.
✓ Branch 4 taken 1186 times.
✓ Branch 5 taken 1759 times.
✓ Branch 6 taken 1186 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 284 times.
✓ Branch 9 taken 902 times.
126382 else if (hoverclk < 1 && !inair && fall == 0 && !IsSideSwim() && justmoved <= 0)
8629 {
8630 902 needFall = true;
8631
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 174 times.
902 if (replay_version_check(0, 23))
8632 {
8633 728 zfix my = y + 4;
8634
2/2
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 1971 times.
2573 for (zfix ty = y + 1; ty < my; ++ty)
8635 {
8636
2/2
✓ Branch 0 taken 1845 times.
✓ Branch 1 taken 126 times.
1971 if (on_sideview_solid_oldpos(this, false, 0, 0, ty-y))
8637 {
8638 126 y = ty;
8639
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if (check_new_slope(x, ty + 1, 16, 16, old_x, old_y, false) < 0)
8640 {
8641 if (!slopeid)
8642 slopeid = get_new_slope(x, ty + 1, 16, 16, old_x, old_y).get_info().slope();
8643 onplatid = 1;
8644 }
8645 126 needFall = false;
8646 126 break;
8647 }
8648 1845 }
8649 728 }
8650 else
8651 {
8652 174 zfix dy = 0;
8653 174 bool landed = false;
8654
3/6
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 174 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 174 times.
✗ Branch 5 not taken.
3132 dy = binary_search_zfix(0, 4, [&](zfix val, zfix& retval)
8655 {
8656
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 2784 times.
2958 if (on_sideview_solid_oldpos(this, false, 0, 0, val))
8657 {
8658 174 retval = val;
8659 174 landed = true;
8660 174 return BSEARCH_CONTINUE_TOWARD0;
8661 }
8662 2784 else return BSEARCH_CONTINUE_AWAY0;
8663 2958 });
8664
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 168 times.
174 if (dy)
8665 {
8666 168 push_move(0, dy);
8667 168 }
8668
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 168 times.
174 if (landed)
8669 {
8670
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 24 times.
168 if (check_new_slope(x, y + 0.0001_zf, 16, 16, old_x, old_y, false, true) < 0)
8671 {
8672
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 24 times.
144 if (!slopeid)
8673 24 slopeid = get_new_slope(x, y + 0.0001_zf, 16, 16, old_x, old_y).get_info().slope();
8674 144 onplatid = 1;
8675 144 }
8676 168 needFall = false;
8677 168 }
8678 }
8679 902 }
8680 125480 else needFall = true;
8681 // Continue falling.
8682
8683
4/4
✓ Branch 0 taken 248191 times.
✓ Branch 1 taken 7434 times.
✓ Branch 2 taken 129537 times.
✓ Branch 3 taken 118654 times.
255625 if(fall <= termv && needFall)
8684 {
8685 118654 inair = true;
8686
3/4
✓ Branch 0 taken 47095 times.
✓ Branch 1 taken 71559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47095 times.
118654 if(fall != 0 || hoverclk>0)
8687 71559 jumping++;
8688
8689 // Bump head if: hit a solid combo from beneath, or hit a solid combo in the screen above this one.
8690
2/2
✓ Branch 0 taken 116656 times.
✓ Branch 1 taken 1998 times.
118654 if(get_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON))
8691 {
8692
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 116656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116656 times.
✓ Branch 4 taken 116065 times.
✓ Branch 5 taken 591 times.
233312 if((_walkflag(x+4,y-(bigHitbox?9:1),0,SWITCHBLOCK_STATE)
8693
4/4
✓ Branch 0 taken 111190 times.
✓ Branch 1 taken 5466 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 110284 times.
116656 || (y<=(bigHitbox?9:1) &&
8694 // Extra checks if Smart Screen Scrolling is enabled
8695
2/6
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 906 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
906 (nextcombo_wf(up) || ((get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8696 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8697
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
5466 && fall < 0)
8698 {
8699 591 fall = jumping = 0; // Bumped his head
8700
8701 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8702
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 110 times.
591 if ( !get_qr(qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8703 {
8704 110 checkdamagecombos(x+4, x+12, y-1, y-1);
8705 110 }
8706 591 }
8707 116656 }
8708 else
8709 {
8710
10/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1998 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1998 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1998 times.
✓ Branch 6 taken 15 times.
✓ Branch 7 taken 1983 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1983 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1983 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1983 times.
✓ Branch 14 taken 1995 times.
✓ Branch 15 taken 3 times.
3996 if((_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE)
8711
2/4
✓ Branch 0 taken 1983 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1983 times.
1983 || ((y<=0) &&
8712 // Extra checks if Smart Screen Scrolling is enabled
8713 (nextcombo_wf(up) || ((get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8714 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8715
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
15 && fall < 0)
8716 {
8717 3 fall = jumping = 0; // Bumped his head
8718 3 y -= y.getInt()%8; //fix coords
8719 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( !get_qr(qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8721 {
8722 3 checkdamagecombos(x+4, x+12, y-1, y-1);
8723 3 }
8724 3 }
8725 }
8726
8727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118654 times.
118654 if(hoverclk > 0)
8728 {
8729 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8730 {
8731 --hoverclk;
8732 }
8733
8734 if(!hoverclk && !ladderx && !laddery)
8735 {
8736 fall += gravity3;
8737 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8738 }
8739 }
8740
5/12
✓ Branch 0 taken 85896 times.
✓ Branch 1 taken 32758 times.
✓ Branch 2 taken 47795 times.
✓ Branch 3 taken 38101 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47795 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
118654 else if(fall+gravity3 > 0 && fall<=0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
8741 {
8742 int32_t itemid = current_item_id(itype_hoverboots);
8743 if(hoverclk < 0)
8744 hoverclk = -hoverclk;
8745 else
8746 {
8747 fall = jumping = 0;
8748 if(itemsbuf[itemid].misc1)
8749 hoverclk = itemsbuf[itemid].misc1;
8750 else
8751 {
8752 hoverclk = 1;
8753 hoverflags |= HOV_INF;
8754 }
8755
8756
8757 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8758 }
8759 if(itemsbuf[itemid].wpn)
8760 decorations.add(new dHover(x, y, dHOVER, 0));
8761 }
8762
4/8
✓ Branch 0 taken 118654 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 118654 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 118654 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 118654 times.
118654 else if(!ladderx && !laddery && !getOnSideviewLadder() && !IsSideSwim())
8763 {
8764 118654 fall += gravity3;
8765
8766 118654 }
8767 118654 }
8768 255625 }
8769 else // Topdown gravity
8770 {
8771
4/4
✓ Branch 0 taken 27717610 times.
✓ Branch 1 taken 13914558 times.
✓ Branch 2 taken 13911100 times.
✓ Branch 3 taken 3458 times.
41632168 if (!(moveflags & move_no_fake_z)) fakez-=fakefall/(spins && fakefall>0 ? 200:100);
8772
4/4
✓ Branch 0 taken 27717610 times.
✓ Branch 1 taken 13914558 times.
✓ Branch 2 taken 13911100 times.
✓ Branch 3 taken 3458 times.
41632168 if (!(moveflags & move_no_real_z)) z-=fall/(spins && fall>0 ? 200:100);
8773
4/4
✓ Branch 0 taken 13895919 times.
✓ Branch 1 taken 27736249 times.
✓ Branch 2 taken 27754888 times.
✓ Branch 3 taken 41650807 times.
41632168 if(z>0||fakez>0)
8774 {
8775
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18639 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55491137 switch(action)
8776 {
8777 case swimming:
8778 {
8779 diveclk=0;
8780 action=walking; FFCore.setHeroAction(walking);
8781
8782 break;
8783 }
8784 case waterhold1:
8785 {
8786 action=landhold1; FFCore.setHeroAction(landhold1);
8787 break;
8788 }
8789
8790 case waterhold2:
8791 {
8792 action=landhold2; FFCore.setHeroAction(landhold2);
8793 break;
8794 }
8795
8796 default:
8797 18639 break;
8798 }
8799 18639 }
8800
8801
2/2
✓ Branch 0 taken 160107 times.
✓ Branch 1 taken 41669446 times.
41829553 for(int32_t j=0; j<chainlinks.Count(); j++)
8802 {
8803 160107 chainlinks.spr(j)->z=z;
8804 160107 chainlinks.spr(j)->fakez=fakez;
8805 160107 }
8806
8807
2/2
✓ Branch 0 taken 41624602 times.
✓ Branch 1 taken 44844 times.
41669446 if(Lwpns.idFirst(wHookshot)>-1)
8808 {
8809 44844 Lwpns.spr(Lwpns.idFirst(wHookshot))->z=z;
8810 44844 Lwpns.spr(Lwpns.idFirst(wHookshot))->fakez=fakez;
8811 44844 }
8812
8813
2/2
✓ Branch 0 taken 41622170 times.
✓ Branch 1 taken 47276 times.
41669446 if(Lwpns.idFirst(wHSHandle)>-1)
8814 {
8815 47276 Lwpns.spr(Lwpns.idFirst(wHSHandle))->z=z;
8816 47276 Lwpns.spr(Lwpns.idFirst(wHSHandle))->fakez=fakez;
8817 47276 }
8818
8819
3/4
✓ Branch 0 taken 13895919 times.
✓ Branch 1 taken 27773527 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13895919 times.
41669446 if(z<=0&&!(moveflags & move_no_real_z))
8820 {
8821
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13895919 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13895919 if (fakez <= 0 || (moveflags & move_no_fake_z))
8822 {
8823
2/2
✓ Branch 0 taken 13895486 times.
✓ Branch 1 taken 433 times.
13895919 if(fall > 0)
8824 {
8825
7/8
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 423 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 411 times.
✓ Branch 7 taken 22 times.
433 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8826 22 sfx(WAV_ZN1SPLASH,x.getInt());
8827
8828 433 stomping = true;
8829 433 }
8830 13895919 }
8831 13895919 z = fall = 0;
8832
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13895919 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13895919 if (fakez <= 0 || (moveflags & move_no_fake_z))
8833 {
8834 13895919 jumping = 0;
8835
2/2
✓ Branch 0 taken 13891767 times.
✓ Branch 1 taken 4152 times.
13895919 if(check_pitslide(true) == -1)
8836 {
8837 13891767 hoverclk = 0;
8838 13891767 hoverflags = 0;
8839 13891767 }
8840
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 4135 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
4152 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8841 {
8842
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!--hoverclk)
8843 {
8844 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8845 }
8846 17 }
8847 13895919 }
8848 13895919 }
8849
3/4
✓ Branch 0 taken 13914558 times.
✓ Branch 1 taken 27754888 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13914558 times.
41669446 if(fakez<=0&&!(moveflags & move_no_fake_z))
8850 {
8851
3/4
✓ Branch 0 taken 18639 times.
✓ Branch 1 taken 13895919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18639 times.
13914558 if (z <= 0 || (moveflags & move_no_real_z))
8852 {
8853
1/2
✓ Branch 0 taken 13895919 times.
✗ Branch 1 not taken.
13895919 if(fakefall > 0)
8854 {
8855 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8856 sfx(WAV_ZN1SPLASH,x.getInt());
8857
8858 stomping = true;
8859 }
8860 13895919 }
8861 13914558 fakez = fakefall = 0;
8862
3/4
✓ Branch 0 taken 18639 times.
✓ Branch 1 taken 13895919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18639 times.
13914558 if (z <= 0 || (moveflags & move_no_real_z))
8863 {
8864 13895919 jumping = 0;
8865
2/2
✓ Branch 0 taken 13891767 times.
✓ Branch 1 taken 4152 times.
13895919 if(check_pitslide(true) == -1)
8866 {
8867 13891767 hoverclk = 0;
8868 13891767 hoverflags = 0;
8869 13891767 }
8870
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 4135 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
4152 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8871 {
8872
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!--hoverclk)
8873 {
8874 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8875 }
8876 17 }
8877 13895919 }
8878 13914558 }
8879
8/10
✓ Branch 0 taken 13914476 times.
✓ Branch 1 taken 27754970 times.
✓ Branch 2 taken 13914476 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13877444 times.
✓ Branch 5 taken 37032 times.
✓ Branch 6 taken 13896001 times.
✓ Branch 7 taken 13896001 times.
✓ Branch 8 taken 13896001 times.
✗ Branch 9 not taken.
41669446 if(fall <= termv && !(moveflags & move_no_real_z) && z>0 || fakefall <= termv && !(moveflags & move_no_fake_z) && fakez > 0)
8880 {
8881
4/6
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 15484 times.
✓ Branch 2 taken 3073 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3073 times.
27773445 if(fall != 0 || fakefall != 0 || hoverclk>0)
8882 15484 jumping++;
8883
8884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18557 times.
18557 if(hoverclk > 0)
8885 {
8886 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8887 {
8888 --hoverclk;
8889 }
8890
8891 if(!hoverclk)
8892 {
8893 if (fall <= termv && !(moveflags & move_no_real_z) && z > 0) fall += gravity3;
8894 if (fakefall <= termv && !(moveflags & move_no_fake_z) && fakez > 0) fakefall += gravity3;
8895 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8896 }
8897 }
8898
9/16
✓ Branch 0 taken 10818 times.
✓ Branch 1 taken 7739 times.
✓ Branch 2 taken 3136 times.
✓ Branch 3 taken 7682 times.
✓ Branch 4 taken 3136 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15421 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15421 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15421 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 18557 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
18557 else if(((fall+(int32_t)(zinit.gravity / 100) > 0 && fall<=0 && !(moveflags & move_no_real_z) && z > 0) || (fakefall+gravity3 > 0 && fakefall<=0 && !(moveflags & move_no_fake_z) && fakez > 0)) && can_use_item(itype_hoverboots,i_hoverboots) && !(hoverflags & HOV_OUT))
8899 {
8900 if(hoverclk < 0)
8901 hoverclk = -hoverclk;
8902 else
8903 {
8904 fall = 0;
8905 fakefall = 0;
8906 int32_t itemid = current_item_id(itype_hoverboots);
8907 if(itemsbuf[itemid].misc1)
8908 hoverclk = itemsbuf[itemid].misc1;
8909 else
8910 {
8911 hoverclk = 1;
8912 hoverflags |= HOV_INF;
8913 }
8914 sfx(itemsbuf[current_item_id(itype_hoverboots)].usesound,pan(x.getInt()));
8915 }
8916 decorations.add(new dHover(x, y, dHOVER, 0));
8917 }
8918 else
8919 {
8920
3/6
✓ Branch 0 taken 18557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18557 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18557 times.
18557 if (fall <= termv && !(moveflags & move_no_real_z) && z > 0) fall += gravity3;
8921
3/6
✓ Branch 0 taken 18557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18557 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18557 times.
✗ Branch 5 not taken.
18557 if (fakefall <= termv && !(moveflags & move_no_fake_z) && fakez > 0) fakefall += gravity3;
8922 }
8923 18557 }
8924
1/2
✓ Branch 0 taken 13914558 times.
✗ Branch 1 not taken.
13914558 if (fakez<0) fakez = 0;
8925
1/2
✓ Branch 0 taken 13914558 times.
✗ Branch 1 not taken.
13914558 if (z<0) z = 0;
8926 }
8927
8928
2/2
✓ Branch 0 taken 14169435 times.
✓ Branch 1 taken 748 times.
14170183 if(drunkclk)
8929 {
8930 748 --drunkclk;
8931 748 }
8932
8933
2/2
✓ Branch 0 taken 14169856 times.
✓ Branch 1 taken 327 times.
14170183 if(lstunclock > 0)
8934 {
8935 // also cancel Hero's attack
8936 327 attackclk = 0;
8937
8938
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 243 times.
327 if( FFCore.getHeroAction() != stunned )
8939 {
8940 243 tempaction=action; //update so future checks won't do this
8941 //action=freeze; //setting this makes the player invincible while stunned -V
8942 243 FFCore.setHeroAction(stunned);
8943 243 }
8944 327 --lstunclock;
8945 327 }
8946 //if the stun action is still set in FFCore, but he isn't stunned, then the timer reached 0
8947 //, so we unfreeze him here, and return him to the action that he had when he was stunned.
8948
4/4
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 14169856 times.
✓ Branch 2 taken 311 times.
✓ Branch 3 taken 16 times.
14170183 if ( FFCore.getHeroAction() == stunned && !lstunclock )
8949 {
8950 16 action=tempaction; FFCore.setHeroAction(tempaction);
8951 //zprint("Unfreezing hero to action: %d\n", (int32_t)tempaction);
8952 //action=none; FFCore.setHeroAction(none);
8953 16 }
8954
8955
1/2
✓ Branch 0 taken 14170183 times.
✗ Branch 1 not taken.
14170183 if( lbunnyclock > 0 )
8956 {
8957 --lbunnyclock;
8958 }
8959
2/2
✓ Branch 0 taken 1925 times.
✓ Branch 1 taken 14168258 times.
14170183 if(DMaps[currdmap].flags&dmfBUNNYIFNOPEARL)
8960 {
8961 1925 int32_t itemid = current_item_id(itype_pearl);
8962
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 1802 times.
1925 if(itemid > -1)
8963 {
8964
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 1 times.
123 if(lbunnyclock == -1) //cure dmap-caused bunny effect
8965 1 lbunnyclock = 0;
8966 123 }
8967
2/2
✓ Branch 0 taken 1801 times.
✓ Branch 1 taken 1 times.
1802 else if(lbunnyclock > -1) //No pearl, force into bunny mode
8968 {
8969 1 lbunnyclock = -1;
8970 1 }
8971 1925 }
8972
1/2
✓ Branch 0 taken 14168258 times.
✗ Branch 1 not taken.
14168258 else if(lbunnyclock == -1) //dmap-caused bunny effect
8973 {
8974 lbunnyclock = 0;
8975 }
8976
8977
7/20
✗ Branch 0 not taken.
✓ Branch 1 taken 14170183 times.
✓ Branch 2 taken 14170183 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14170183 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14170183 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 14170183 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 14170183 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 14170183 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
28340366 bool is_broken_behavior = replay_is_active() && replay_get_meta_str("sav") == "link_to_the_zelda_2_of_3.sav";
8978
5/6
✓ Branch 0 taken 143268 times.
✓ Branch 1 taken 14026915 times.
✓ Branch 2 taken 18285 times.
✓ Branch 3 taken 124983 times.
✓ Branch 4 taken 14045200 times.
✗ Branch 5 not taken.
28215383 bool fall_check = (fall == 0 || z > 0) && (fakefall == 0 || fakez > 0);
8979
2/2
✓ Branch 0 taken 13853390 times.
✓ Branch 1 taken 316793 times.
14170183 if (is_broken_behavior)
8980
5/6
✓ Branch 0 taken 1196 times.
✓ Branch 1 taken 315597 times.
✓ Branch 2 taken 156 times.
✓ Branch 3 taken 1040 times.
✓ Branch 4 taken 1040 times.
✗ Branch 5 not taken.
316793 fall_check = (fall == 0 || z > 0) || (fakefall == 0 || fakez > 0);
8981
8982
12/14
✓ Branch 0 taken 14115464 times.
✓ Branch 1 taken 54719 times.
✓ Branch 2 taken 9703358 times.
✓ Branch 3 taken 4412106 times.
✓ Branch 4 taken 9703358 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9703358 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9703348 times.
✓ Branch 9 taken 10 times.
✓ Branch 10 taken 9701539 times.
✓ Branch 11 taken 1809 times.
✓ Branch 12 taken 78688 times.
✓ Branch 13 taken 9622257 times.
14170183 if(!is_on_conveyor && !(diagonalMovement||NO_GRIDLOCK) && fall_check && charging==0 && spins<=5
8983
2/2
✓ Branch 0 taken 9700945 times.
✓ Branch 1 taken 594 times.
9701539 && action != gothit)
8984 {
8985
2/3
✓ Branch 0 taken 4349346 times.
✓ Branch 1 taken 5272911 times.
✗ Branch 2 not taken.
9622257 switch(dir)
8986 {
8987 case up:
8988 case down:
8989 4349346 x=(x.getInt()+4)&0xFFF8;
8990 4349346 break;
8991
8992 case left:
8993 case right:
8994 5272911 y=(y.getInt()+4)&0xFFF8;
8995 5272911 break;
8996 }
8997 9622257 }
8998
8999
4/4
✓ Branch 0 taken 137817 times.
✓ Branch 1 taken 14032366 times.
✓ Branch 2 taken 52294 times.
✓ Branch 3 taken 85523 times.
14170183 if((watch==true) && clockclk)
9000 {
9001 52294 --clockclk;
9002
9003
2/2
✓ Branch 0 taken 52151 times.
✓ Branch 1 taken 143 times.
52294 if(!clockclk)
9004 {
9005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 if(cheat_superman==false)
9006 {
9007 143 setClock(false);
9008 143 }
9009
9010 143 watch=false;
9011
9012
2/2
✓ Branch 0 taken 73216 times.
✓ Branch 1 taken 143 times.
73359 for(int32_t i=0; i<eMAXGUYS; i++)
9013 {
9014
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 73216 times.
73223 for(int32_t zoras=0; zoras<clock_zoras[i]; zoras++)
9015 {
9016 7 addenemy(0,0,i,0);
9017 7 }
9018 73216 }
9019 143 }
9020 52294 }
9021
9022
4/4
✓ Branch 0 taken 14122907 times.
✓ Branch 1 taken 47276 times.
✓ Branch 2 taken 8704 times.
✓ Branch 3 taken 14114203 times.
14170183 if(hookshot_frozen || switch_hooked)
9023 {
9024
4/4
✓ Branch 0 taken 11136 times.
✓ Branch 1 taken 44844 times.
✓ Branch 2 taken 8704 times.
✓ Branch 3 taken 2432 times.
55980 if(hookshot_used || switch_hooked)
9025 {
9026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53548 times.
53548 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
9027 53548 else {action=freeze; FFCore.setHeroAction(freeze);} //could be LA_HOOKSHOT for FFCore. -Z
9028
9029
3/4
✓ Branch 0 taken 36199 times.
✓ Branch 1 taken 17349 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36199 times.
53548 if(pull_hero || switch_hooked)
9030 {
9031
3/4
✓ Branch 0 taken 8585 times.
✓ Branch 1 taken 8764 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8585 times.
17349 if(hs_switcher || switch_hooked)
9032 {
9033 8764 hs_fix = false;
9034
1/2
✓ Branch 0 taken 8764 times.
✗ Branch 1 not taken.
8764 if(switchhookclk)
9035 {
9036 8764 --switchhookclk;
9037
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 8627 times.
8764 if(switchhookclk==switchhookmaxtime/2) //Perform swaps
9038 {
9039
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 137 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
137 if(switchhook_cost_item > -1 && !checkmagiccost(switchhook_cost_item))
9040 reset_hookshot();
9041 else
9042 {
9043 137 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
9044 137 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
9045
9046
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 5 times.
137 if(hooked_combopos > -1) //Switching combos
9047 {
9048 132 uint16_t targpos = hooked_combopos, plpos = COMBOPOS(x+8,y+8);
9049
3/6
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 132 times.
132 if(targpos < 176 && plpos < 176 && hooked_layerbits)
9050 {
9051
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 int32_t max_layer = get_qr(qr_HOOKSHOTALLLAYER) ? 6 : (get_qr(qr_HOOKSHOTLAYERFIX) ? 2 : 0);
9052
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 132 times.
1056 for(int q = max_layer; q > -1; --q)
9053 {
9054
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 792 times.
924 if(!(hooked_layerbits & (1<<q)))
9055 792 continue; //non-switching layer
9056 132 mapscr* scr = FFCore.tempScreens[q];
9057 132 newcombo const& cmb = combobuf[scr->data[targpos]];
9058 132 int32_t srcfl = scr->sflag[targpos];
9059 132 newcombo const& comb2 = combobuf[scr->data[plpos]];
9060 132 int32_t c = scr->data[plpos], cs = scr->cset[plpos], fl = scr->sflag[plpos];
9061 //{Check push status
9062 132 bool isFakePush = false;
9063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(cmb.type == cSWITCHHOOK)
9064 {
9065
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag7) //counts as 'pushblock'
9066 isFakePush = true;
9067 132 }
9068 132 bool isPush = isFakePush;
9069
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(srcfl)
9070 {
9071 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
9072 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
9073 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
9074 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
9075 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
9076 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
9077 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
9078 isPush = true;
9079 132 }
9080
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(cmb.flag)
9081 {
9082 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
9083 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
9084 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
9085 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
9086 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
9087 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
9088 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
9089 isPush = true;
9090 132 }
9091
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(srcfl==mfPUSHED) isPush = false;
9092 //}
9093
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.type == cSWITCHHOOK) //custom flags and such
9094 {
9095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(cmb.usrflags&cflag3) //Breaks on swap
9096 {
9097 int32_t it = -1;
9098 int32_t thedropset = -1;
9099 if(cmb.usrflags&cflag4) //drop item
9100 {
9101 if(cmb.usrflags&cflag5)
9102 it = cmb.attribytes[2];
9103 else
9104 {
9105 it = select_dropitem(cmb.attribytes[2]);
9106 thedropset = cmb.attribytes[2];
9107 }
9108 }
9109
9110 breakable* br = new breakable(x, y, 0_zf,
9111 cmb, scr->cset[targpos], it, thedropset, cmb.attribytes[2],
9112 cmb.attribytes[1] ? -1 : 0, cmb.attribytes[1], switchhookclk);
9113 br->switch_hooked = true;
9114 decorations.add(br);
9115 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
9116 hooked_undercombos[q] = -1;
9117
9118 if(cmb.usrflags&cflag6)
9119 {
9120 scr->data[targpos]++;
9121 }
9122 else
9123 {
9124 scr->data[targpos] = scr->undercombo;
9125 scr->cset[targpos] = scr->undercset;
9126 if(cmb.usrflags&cflag2)
9127 scr->sflag[targpos] = 0;
9128 }
9129 }
9130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 else if(isPush)
9131 {
9132 //Simulate a block clicking into place
9133 movingblock mtemp;
9134 mtemp.clear();
9135 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
9136 mtemp.dir = getPushDir(scr->sflag[targpos]);
9137 if(mtemp.dir < 0)
9138 mtemp.dir = getPushDir(cmb.flag);
9139 mtemp.clk = 1;
9140 mtemp.force_many = isFakePush;
9141 mtemp.no_icy = true;
9142 mtemp.animate(0);
9143 if((mtemp.bhole || mtemp.trigger)
9144 && (fl == mfBLOCKTRIGGER || fl == mfBLOCKHOLE
9145 || comb2.flag == mfBLOCKTRIGGER
9146 || comb2.flag == mfBLOCKHOLE))
9147 {
9148 scr->data[targpos] = scr->undercombo;
9149 scr->cset[targpos] = scr->undercset;
9150 scr->sflag[targpos] = 0;
9151 }
9152 else
9153 {
9154 scr->data[targpos] = c;
9155 scr->cset[targpos] = cs;
9156 if(cmb.usrflags&cflag2)
9157 scr->sflag[targpos] = fl;
9158 else
9159 scr->sflag[targpos] = 0;
9160 }
9161 }
9162 else
9163 {
9164 132 scr->data[plpos] = scr->data[targpos];
9165 132 scr->cset[plpos] = scr->cset[targpos];
9166
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag2)
9167 scr->sflag[plpos] = scr->sflag[targpos];
9168 132 scr->data[targpos] = c;
9169 132 scr->cset[targpos] = cs;
9170
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag2)
9171 scr->sflag[targpos] = fl;
9172 }
9173 132 }
9174 else if(isCuttableType(cmb.type)) //Break and drop effects
9175 {
9176 int32_t breakcs = scr->cset[targpos];
9177 if(isCuttableNextType(cmb.type)) //next instead of undercmb
9178 {
9179 scr->data[targpos]++;
9180 }
9181 else
9182 {
9183 scr->data[targpos] = scr->undercombo;
9184 scr->cset[targpos] = scr->undercset;
9185 scr->sflag[targpos] = 0;
9186 }
9187
9188 int32_t it = -1;
9189 int32_t thedropset = -1;
9190 if(isCuttableItemType(cmb.type)) //Drop an item
9191 {
9192 if ( (cmb.usrflags&cflag2) )
9193 {
9194 if(cmb.usrflags&cflag11)
9195 it = cmb.attribytes[1];
9196 else
9197 {
9198 it = select_dropitem(cmb.attribytes[1]);
9199 thedropset = cmb.attribytes[1];
9200 }
9201 }
9202 else
9203 {
9204 it = select_dropitem(12);
9205 thedropset = 12;
9206 }
9207 }
9208
9209 byte breaksfx = 0;
9210 if(get_qr(qr_MORESOUNDS)) //SFX
9211 {
9212 if (cmb.usrflags&cflag3)
9213 {
9214 breaksfx = cmb.attribytes[2];
9215 }
9216 else if(isBushType(cmb.type)
9217 || isFlowersType(cmb.type)
9218 || isGrassType(cmb.type))
9219 {
9220 breaksfx = QMisc.miscsfx[sfxBUSHGRASS];
9221 }
9222 }
9223
9224 //Clipping sprite
9225 int16_t decotype = (cmb.usrflags & cflag1) ?
9226 ((cmb.usrflags & cflag10)
9227 ? (cmb.attribytes[0])
9228 : (-1))
9229 : (0);
9230 if(decotype > 3) decotype = 0;
9231 if(!decotype)
9232 decotype = (isBushType(cmb.type) ? 1
9233 : (isFlowersType(cmb.type) ? 2
9234 : (isGrassType(cmb.type) ? 3
9235 : ((cmb.usrflags & cflag1) ? -1
9236 : -2))));
9237
9238 breakable* br = new breakable(x, y, 0_zf,
9239 cmb, breakcs, it, thedropset, breaksfx,
9240 decotype, cmb.attribytes[0], switchhookclk);
9241 br->switch_hooked = true;
9242 decorations.add(br);
9243 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
9244 hooked_undercombos[q] = -1;
9245 }
9246 else //Unknown type, just swap combos.
9247 {
9248 if(isPush)
9249 {
9250 //Simulate a block clicking into place
9251 movingblock mtemp;
9252 mtemp.clear();
9253 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
9254 mtemp.dir = getPushDir(scr->sflag[targpos]);
9255 if(mtemp.dir < 0)
9256 mtemp.dir = getPushDir(cmb.flag);
9257 mtemp.clk = 1;
9258 mtemp.animate(0);
9259 if(mtemp.bhole || mtemp.trigger)
9260 {
9261 scr->data[targpos] = scr->undercombo;
9262 scr->cset[targpos] = scr->undercset;
9263 scr->sflag[targpos] = 0;
9264 }
9265 else
9266 {
9267 scr->data[targpos] = c;
9268 scr->cset[targpos] = cs;
9269 scr->sflag[targpos] = 0;
9270 }
9271 }
9272 else
9273 {
9274 scr->data[plpos] = scr->data[targpos];
9275 scr->cset[plpos] = scr->cset[targpos];
9276 scr->data[targpos] = c;
9277 scr->cset[targpos] = cs;
9278 }
9279 }
9280 132 }
9281
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(switchhook_cost_item > -1)
9282 paymagiccost(switchhook_cost_item);
9283 132 zfix tx = x, ty = y;
9284 //Position the player at the combo
9285 132 x = COMBOX(targpos);
9286 132 y = COMBOY(targpos);
9287 132 dir = oppositeDir[dir];
9288
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
132 if(w && hw)
9289 {
9290 //Calculate chain shift
9291 zfix dx = (x-tx);
9292 zfix dy = (y-ty);
9293 if(w->dir < 4)
9294 {
9295 if(w->dir & 2)
9296 dx = 0;
9297 else dy = 0;
9298 }
9299 //Position the hook head at the handle
9300 w->x = hw->x + dx;
9301 w->y = hw->y + dy;
9302 w->dir = oppositeDir[w->dir];
9303 w->doAutoRotate(true);
9304 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
9305 w->flip ^= hflip;
9306 //Position the handle appropriately
9307 hw->x = x-(hw->x-tx);
9308 hw->y = y-(hw->y-ty);
9309 hw->dir = oppositeDir[hw->dir];
9310 hw->doAutoRotate(true);
9311 hw->flip ^= hflip;
9312 //Move chains
9313 for(int32_t j=0; j<chainlinks.Count(); j++)
9314 {
9315 chainlinks.spr(j)->x += dx;
9316 chainlinks.spr(j)->y += dy;
9317 }
9318 }
9319 132 hooked_combopos = plpos; //flip positions
9320 132 }
9321 else reset_hookshot();
9322 132 }
9323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 else if(switching_object) //Switching an object
9324 {
9325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(switchhook_cost_item > -1)
9326 paymagiccost(switchhook_cost_item);
9327 5 zfix tx = x, ty = y;
9328 //Position the player at the object
9329 5 x = switching_object->x;
9330 5 y = switching_object->y;
9331 5 dir = oppositeDir[dir];
9332 //Position the object at the player
9333 5 switching_object->x = tx;
9334 5 switching_object->y = ty;
9335
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
5 if(switching_object->dir == dir || switching_object->dir == oppositeDir[dir])
9336 2 switching_object->dir = oppositeDir[switching_object->dir];
9337 5 solid_update(false);
9338 5 switching_object->solid_update(false);
9339
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if(item* it = dynamic_cast<item*>(switching_object))
9340 {
9341 if(itemsbuf[it->id].family == itype_fairy && itemsbuf[it->id].misc3)
9342 {
9343 movefairynew2(it->x, it->y, *it);
9344 }
9345 }
9346
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
5 if(w && hw) //!TODO No fucking clue if diagonals work
9347 {
9348 //Calculate chain shift
9349 1 zfix dx = (x-tx);
9350 1 zfix dy = (y-ty);
9351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(w->dir < 4)
9352 {
9353
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(w->dir & 2)
9354 1 dx = 0;
9355 else dy = 0;
9356 1 }
9357 //Position the hook head at the handle
9358 1 w->x = hw->x + dx;
9359 1 w->y = hw->y + dy;
9360 1 w->dir = oppositeDir[w->dir];
9361 1 w->doAutoRotate(true);
9362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
9363 1 w->flip ^= hflip;
9364 1 w->solid_update(false);
9365 //Position the handle appropriately
9366 1 hw->x = x-(hw->x-tx);
9367 1 hw->y = y-(hw->y-ty);
9368 1 hw->dir = oppositeDir[hw->dir];
9369 1 hw->doAutoRotate(true);
9370 1 hw->flip ^= hflip;
9371 1 hw->solid_update(false);
9372 //Move chains
9373
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for(int32_t j=0; j<chainlinks.Count(); j++)
9374 {
9375 5 chainlinks.spr(j)->x += dx;
9376 5 chainlinks.spr(j)->y += dy;
9377 5 }
9378 1 }
9379 5 }
9380 }
9381 137 }
9382
2/2
✓ Branch 0 taken 8490 times.
✓ Branch 1 taken 137 times.
8627 else if(!switchhookclk)
9383 {
9384 137 reset_hookshot();
9385 137 }
9386 8764 }
9387 else reset_hookshot();
9388 8764 }
9389 else
9390 {
9391 sprite *t;
9392 int32_t i;
9393
9394
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8761 times.
✓ Branch 2 taken 176 times.
✓ Branch 3 taken 8585 times.
8761 for(i=0; i<Lwpns.Count() && (Lwpns.spr(i)->id!=wHSHandle); i++)
9395 {
9396 /* do nothing */
9397 176 }
9398
9399 8585 t = Lwpns.spr(i);
9400
9401
2/2
✓ Branch 0 taken 17399 times.
✓ Branch 1 taken 8585 times.
25984 for(i=0; i<Lwpns.Count(); i++)
9402 {
9403 17399 sprite *s = Lwpns.spr(i);
9404
9405
2/2
✓ Branch 0 taken 8814 times.
✓ Branch 1 taken 8585 times.
17399 if(s->id==wHookshot)
9406 {
9407
2/2
✓ Branch 0 taken 2098 times.
✓ Branch 1 taken 6487 times.
8585 if (abs((s->y) - y) >= 1)
9408 {
9409
2/2
✓ Branch 0 taken 1219 times.
✓ Branch 1 taken 879 times.
2098 if((s->y)>y)
9410 {
9411 879 y+=4;
9412
9413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 879 times.
879 if(Lwpns.idFirst(wHSHandle)!=-1)
9414 {
9415 879 t->y+=4;
9416 879 }
9417
9418 879 hs_starty+=4;
9419 879 }
9420
9421
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 1219 times.
2098 if((s->y)<y)
9422 {
9423 1219 y-=4;
9424
9425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1219 times.
1219 if(Lwpns.idFirst(wHSHandle)!=-1)
9426 {
9427 1219 t->y-=4;
9428 1219 }
9429
9430 1219 hs_starty-=4;
9431 1219 }
9432 2098 }
9433 else
9434 {
9435 6487 y = (s->y);
9436 }
9437
2/2
✓ Branch 0 taken 6487 times.
✓ Branch 1 taken 2098 times.
8585 if (abs((s->x) - x) >= 1)
9438 {
9439
2/2
✓ Branch 0 taken 3152 times.
✓ Branch 1 taken 3335 times.
6487 if((s->x)>x)
9440 {
9441 3335 x+=4;
9442
9443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3335 times.
3335 if(Lwpns.idFirst(wHSHandle)!=-1)
9444 {
9445 3335 t->x+=4;
9446 3335 }
9447
9448 3335 hs_startx+=4;
9449 3335 }
9450
9451
2/2
✓ Branch 0 taken 3335 times.
✓ Branch 1 taken 3152 times.
6487 if((s->x)<x)
9452 {
9453 3152 x-=4;
9454
9455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3152 times.
3152 if(Lwpns.idFirst(wHSHandle)!=-1)
9456 {
9457 3152 t->x-=4;
9458 3152 }
9459
9460 3152 hs_startx-=4;
9461 3152 }
9462 6487 }
9463 else
9464 {
9465 2098 x = (s->x);
9466 }
9467 8585 }
9468 17399 }
9469 }
9470 17349 }
9471 53548 }
9472 else
9473 {
9474 2432 Lwpns.del(Lwpns.idFirst(wHSHandle));
9475 2432 reset_hookshot();
9476 }
9477
9478
1/2
✓ Branch 0 taken 55980 times.
✗ Branch 1 not taken.
55980 if(hs_fix)
9479 {
9480 if(dir==up)
9481 {
9482 y=int32_t(y+7)&0xF0;
9483 }
9484
9485 if(dir==down)
9486 {
9487 y=int32_t(y+7)&0xF0;
9488 }
9489
9490 if(dir==left)
9491 {
9492 x=int32_t(x+7)&0xF0;
9493 }
9494
9495 if(dir==right)
9496 {
9497 x=int32_t(x+7)&0xF0;
9498 }
9499
9500 hs_fix=false;
9501 }
9502
9503 55980 }
9504
9505
2/2
✓ Branch 0 taken 1262482 times.
✓ Branch 1 taken 12907701 times.
14170183 if(!get_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP))
9506 {
9507
2/2
✓ Branch 0 taken 5305 times.
✓ Branch 1 taken 12902396 times.
12907701 if(DrunkrLbtn())
9508 5305 selectNextBWpn(SEL_LEFT);
9509
2/2
✓ Branch 0 taken 12894921 times.
✓ Branch 1 taken 7475 times.
12902396 else if(DrunkrRbtn())
9510 7475 selectNextBWpn(SEL_RIGHT);
9511 12907701 }
9512
4/4
✓ Branch 0 taken 949920 times.
✓ Branch 1 taken 13220263 times.
✓ Branch 2 taken 939265 times.
✓ Branch 3 taken 10655 times.
14170183 if (get_qr(qr_SELECTAWPN) && get_qr(qr_USE_EX1_EX2_INVENTORYSWAP))
9513 {
9514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10655 times.
10655 if (rEx3btn())
9515 selectNextAWpn(SEL_LEFT);
9516
2/2
✓ Branch 0 taken 10654 times.
✓ Branch 1 taken 1 times.
10655 else if (rEx4btn())
9517 1 selectNextAWpn(SEL_RIGHT);
9518 10655 }
9519
9520
2/2
✓ Branch 0 taken 14169105 times.
✓ Branch 1 taken 1078 times.
14170183 if(rPbtn())
9521 {
9522
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1075 times.
1078 if( !FFCore.runOnMapScriptEngine() ) //OnMap script replaces the 'onViewMap()' call
9523 1075 onViewMap();
9524 1078 }
9525
2/2
✓ Branch 0 taken 5024332 times.
✓ Branch 1 taken 14170183 times.
19194515 for(int32_t i=0; i<Lwpns.Count(); i++)
9526 {
9527 5024332 weapon *w = ((weapon*)Lwpns.spr(i));
9528
9529
6/6
✓ Branch 0 taken 4973429 times.
✓ Branch 1 taken 50903 times.
✓ Branch 2 taken 4510854 times.
✓ Branch 3 taken 462575 times.
✓ Branch 4 taken 73 times.
✓ Branch 5 taken 4510781 times.
5024332 if(w->id == wArrow || w->id == wBrang || w->id == wCByrna)
9530 513551 addsparkle(i);
9531 5024332 }
9532
9533
2/2
✓ Branch 0 taken 14168948 times.
✓ Branch 1 taken 1235 times.
14170183 if(Lwpns.idCount(wPhantom))
9534 {
9535 1235 addsparkle2(pDIVINEFIREROCKET,pDIVINEFIREROCKETTRAIL);
9536 1235 addsparkle2(pDIVINEFIREROCKETRETURN,pDIVINEFIREROCKETTRAILRETURN);
9537 1235 addsparkle2(pDIVINEPROTECTIONROCKET1,pDIVINEPROTECTIONROCKETTRAIL1);
9538 1235 addsparkle2(pDIVINEPROTECTIONROCKET2,pDIVINEPROTECTIONROCKETTRAIL2);
9539 1235 addsparkle2(pDIVINEPROTECTIONROCKETRETURN1,pDIVINEPROTECTIONROCKETTRAILRETURN1);
9540 1235 addsparkle2(pDIVINEPROTECTIONROCKETRETURN2,pDIVINEPROTECTIONROCKETTRAILRETURN2);
9541 1235 }
9542
9543 // Pay magic cost for Byrna beams
9544
9545 //Byrna needs a secondary timer, for 254+, as do all items that reduce MP on a per-frae basis. Essentially, we will do % divisor == 0 for that. -Z
9546
2/2
✓ Branch 0 taken 14170110 times.
✓ Branch 1 taken 73 times.
14170183 if(Lwpns.idCount(wCByrna))
9547 {
9548 73 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
9549 73 int32_t itemid = ew->parentitem;
9550
9551
2/4
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73 times.
73 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
9552 {
9553 for(int32_t i=0; i<Lwpns.Count(); i++)
9554 {
9555 weapon *w = ((weapon*)Lwpns.spr(i));
9556
9557 if(w->id==wCByrna)
9558 {
9559 w->dead=1;
9560 }
9561
9562 }
9563 //kill the sound effect for the orbits -Z 14FEB2019
9564 stop_sfx(itemsbuf[itemid].usesound);
9565 }
9566 73 else paymagiccost(itemid);
9567 73 }
9568
9569
3/4
✓ Branch 0 taken 14151544 times.
✓ Branch 1 taken 18639 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14151544 times.
14170183 if(z==0&&fakez==0)
9570 {
9571 14151544 switchblock_z = 0;
9572
1/2
✓ Branch 0 taken 14151544 times.
✗ Branch 1 not taken.
14151544 if(switchblock_offset)
9573 {
9574 switchblock_offset=false;
9575 yofs += 8;
9576 }
9577 14151544 }
9578
2/2
✓ Branch 0 taken 255625 times.
✓ Branch 1 taken 13914558 times.
14170183 if(!isSideViewHero())
9579 {
9580 13914558 int32_t tx = x.getInt()+8,
9581 13914558 ty = y.getInt()+8;//(bigHitbox?8:12);
9582
4/4
✓ Branch 0 taken 13914122 times.
✓ Branch 1 taken 436 times.
✓ Branch 2 taken 368 times.
✓ Branch 3 taken 13913754 times.
13914558 if(!(unsigned(ty)>175 || unsigned(tx) > 255))
9583 {
9584
2/2
✓ Branch 0 taken 13913754 times.
✓ Branch 1 taken 41741262 times.
55655016 for(int32_t q = 0; q < 3; ++q)
9585 {
9586
4/4
✓ Branch 0 taken 27827508 times.
✓ Branch 1 taken 13913754 times.
✓ Branch 2 taken 7744794 times.
✓ Branch 3 taken 20082714 times.
41741262 if(q && !tmpscr2[q-1].valid) continue;
9587 21658548 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[COMBOPOS(tx,ty)]];
9588
3/4
✓ Branch 0 taken 4519 times.
✓ Branch 1 taken 21654029 times.
✓ Branch 2 taken 4519 times.
✗ Branch 3 not taken.
21658548 if(cmb.type != cCSWITCHBLOCK || !(cmb.usrflags&cflag9)) continue;
9589 int32_t b = 1;
9590 if(tx&8) b <<= 2;
9591 if(ty&8) b <<= 1;
9592 b |= (b<<4); //check equivalent effect flag too
9593 if((cmb.walk&b)==b) //solid and effecting
9594 {
9595 if(z==0&&fakez==0)
9596 {
9597 if(cmb.usrflags&cflag10)
9598 {
9599 if(!switchblock_offset)
9600 {
9601 switchblock_offset=true;
9602 yofs -= 8;
9603 }
9604 }
9605 else
9606 {
9607 if(switchblock_offset)
9608 {
9609 switchblock_offset=false;
9610 yofs += 8;
9611 }
9612 }
9613 }
9614 if(cmb.attributes[2]>0 && switchblock_z>=0)
9615 {
9616 if(z==0&&fakez==0)
9617 switchblock_z = zc_max(switchblock_z,zslongToFix(cmb.attributes[2]));
9618 else if(SWITCHBLOCK_STATE < zslongToFix(cmb.attributes[2]))
9619 {
9620 switchblock_z += zslongToFix(cmb.attributes[2])-SWITCHBLOCK_STATE;
9621 }
9622 }
9623 else switchblock_z = -1;
9624 break;
9625 }
9626 }
9627 13913754 }
9628 13914558 }
9629 14170183 ClearhitHeroUIDs(); //clear them before we advance.
9630 14170183 checkhit();
9631
9632 14170183 bool forcedeath = dying_flags&DYING_FORCED;
9633 14170183 bool norev = (dying_flags&DYING_NOREV);
9634
4/6
✓ Branch 0 taken 14170183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 560 times.
✓ Branch 3 taken 14169623 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 560 times.
14170183 if(forcedeath || (game->get_life()<=0 && !immortal))
9635 {
9636
1/2
✓ Branch 0 taken 560 times.
✗ Branch 1 not taken.
560 if(forcedeath)
9637 game->set_life(0);
9638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 560 times.
560 if(!norev)
9639
2/2
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 143360 times.
143920 for(size_t slot = 0; slot < 256; ++slot)
9640 {
9641
2/2
✓ Branch 0 taken 143352 times.
✓ Branch 1 taken 8 times.
143360 if(size_t bind = game->get_bottle_slot(slot))
9642 {
9643 8 bottletype const* bt = &QMisc.bottle_types[bind-1];
9644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!(bt->flags&BTFLAG_AUTOONDEATH))
9645 8 continue;
9646 word toFill[3] = { 0 };
9647 for(size_t q = 0; q < 3; ++q)
9648 {
9649 char c = bt->counter[q];
9650 if(c > -1)
9651 {
9652 if(bt->flags & (1<<q))
9653 {
9654 toFill[q] = (bt->amount[q]==100)
9655 ? game->get_maxcounter(c)
9656 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
9657 }
9658 else toFill[q] = bt->amount[q];
9659 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
9660 {
9661 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
9662 }
9663 }
9664 }
9665 if(bt->flags & BTFLAG_CURESWJINX)
9666 {
9667 swordclk = 0;
9668 verifyAWpn();
9669 }
9670 if(bt->flags & BTFLAG_CUREITJINX)
9671 itemclk = 0;
9672 if(bt->flags & BTFLAG_CURESHJINX)
9673 shieldjinxclk = 0;
9674 if(word max = std::max(toFill[0], std::max(toFill[1], toFill[2])))
9675 {
9676 int32_t itemid = find_bottle_for_slot(slot,true);
9677 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
9678 if(itemid > -1)
9679 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
9680 for(size_t q = 0; q < 20; ++q)
9681 do_death_refill_waitframe();
9682 double inc = max/60.0; //1 second
9683 double xtra[3]{ 0 };
9684 for(size_t q = 0; q < 60; ++q)
9685 {
9686 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
9687 sfx(QMisc.miscsfx[sfxREFILL]);
9688 for(size_t j = 0; j < 3; ++j)
9689 {
9690 xtra[j] += inc;
9691 word f = floor(xtra[j]);
9692 xtra[j] -= f;
9693 if(toFill[j] > f)
9694 {
9695 toFill[j] -= f;
9696 game->change_counter(f,bt->counter[j]);
9697 }
9698 else if(toFill[j])
9699 {
9700 game->change_counter(toFill[j],bt->counter[j]);
9701 toFill[j] = 0;
9702 }
9703 }
9704 do_death_refill_waitframe();
9705 }
9706 for(size_t j = 0; j < 3; ++j)
9707 {
9708 if(toFill[j])
9709 {
9710 game->change_counter(toFill[j],bt->counter[j]);
9711 toFill[j] = 0;
9712 }
9713 }
9714 for(size_t q = 0; q < 20; ++q)
9715 do_death_refill_waitframe();
9716 }
9717 game->set_bottle_slot(slot,bt->next_type);
9718 if(game->get_life() > 0)
9719 {
9720 dying_flags = 0;
9721 forcedeath = false;
9722 break; //Revived! Stop drinking things...
9723 }
9724 }
9725 143912 }
9726
9727
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 500 times.
560 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
9728 {
9729
3/6
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
60 if(forcedeath || (game->get_life()<=0 && !immortal)) //Not saved by fairy
9730 {
9731 // So scripts can have one frame to handle hp zero events
9732
3/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 35 times.
60 if(norev || false == (last_hurrah = !last_hurrah))
9733 {
9734 25 dying_flags = 0;
9735 25 drunkclk=0;
9736 25 lstunclock = 0;
9737 25 is_conveyor_stunned = 0;
9738 25 FFCore.setHeroAction(dying);
9739 25 FFCore.deallocateAllScriptOwned(ScriptType::Global, GLOBAL_SCRIPT_GAME);
9740 25 FFCore.deallocateAllScriptOwned(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
9741 25 ALLOFF(true,true);
9742 25 GameFlags |= GAMEFLAG_NO_F6;
9743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!debug_enabled)
9744 {
9745 25 Paused=false;
9746 25 }
9747
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 10 times.
25 if(!get_qr(qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9748 {
9749 10 FFCore.runOnDeathEngine();
9750 10 FFCore.deallocateAllScriptOwned(ScriptType::Player, SCRIPT_PLAYER_DEATH);
9751 10 }
9752 25 Playing = false;
9753 25 heroDeathAnimation();
9754
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 15 times.
25 if(get_qr(qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9755 {
9756 15 Playing = true;
9757 15 FFCore.runOnDeathEngine();
9758 15 FFCore.deallocateAllScriptOwned(ScriptType::Player, SCRIPT_PLAYER_DEATH);
9759 15 Playing = false;
9760 15 }
9761 25 GameFlags &= ~GAMEFLAG_NO_F6;
9762 25 ALLOFF(true,true);
9763 25 return true;
9764 }
9765 35 }
9766 35 }
9767 else //2.50.x
9768 {
9769 // So scripts can have one frame to handle hp zero events
9770
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 251 times.
500 if(false == (last_hurrah = !last_hurrah))
9771 {
9772 249 drunkclk=0;
9773 249 heroDeathAnimation();
9774
9775 249 return true;
9776 }
9777 }
9778 286 }
9779 14169623 else last_hurrah=false;
9780
9781
2/2
✓ Branch 0 taken 14121142 times.
✓ Branch 1 taken 48767 times.
14169909 if(swordclk>0)
9782 {
9783 48767 --swordclk;
9784
2/2
✓ Branch 0 taken 48430 times.
✓ Branch 1 taken 337 times.
48767 if(!swordclk) verifyAWpn();
9785 48767 }
9786
2/2
✓ Branch 0 taken 14160751 times.
✓ Branch 1 taken 9158 times.
14169909 if(itemclk>0)
9787 9158 --itemclk;
9788
1/2
✓ Branch 0 taken 14169909 times.
✗ Branch 1 not taken.
14169909 if(shieldjinxclk>0)
9789 --shieldjinxclk;
9790
9791
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 14168571 times.
14169909 if(inwallm)
9792 {
9793 1338 attackclk=0;
9794 1338 herostep();
9795
9796
2/2
✓ Branch 0 taken 1329 times.
✓ Branch 1 taken 9 times.
1338 if(CarryHero()==false)
9797 9 restart_level();
9798
9799 1338 solid_update(false);
9800 1338 return false;
9801 }
9802
9803
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 14168568 times.
14168571 if(ewind_restart)
9804 {
9805 3 attackclk=0;
9806 3 restart_level();
9807 3 xofs=0;
9808 3 action=none; FFCore.setHeroAction(none);
9809 3 ewind_restart=false;
9810 3 solid_update(false);
9811 3 return false;
9812 }
9813
9814
2/2
✓ Branch 0 taken 14154487 times.
✓ Branch 1 taken 14081 times.
14168568 if(hopclk)
9815 {
9816 14081 action=hopping; FFCore.setHeroAction(hopping);
9817 14081 }
9818
2/2
✓ Branch 0 taken 14164788 times.
✓ Branch 1 taken 3780 times.
14168568 if(fallclk)
9819 {
9820 3780 action=falling; FFCore.setHeroAction(falling);
9821 3780 }
9822
9823
5/6
✓ Branch 0 taken 136379 times.
✓ Branch 1 taken 14032189 times.
✓ Branch 2 taken 1633 times.
✓ Branch 3 taken 134746 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1633 times.
14168568 if(isSwimming() && (liftflags&LIFTFL_DIS_SWIMMING) && !get_qr(qr_BROKEN_LIFTSWIM))
9824 1633 drop_liftwpn();
9825 14168568 handle_passive_buttons();
9826
2/2
✓ Branch 0 taken 1032 times.
✓ Branch 1 taken 14167536 times.
14168568 if(liftclk)
9827 {
9828
1/2
✓ Branch 0 taken 1032 times.
✗ Branch 1 not taken.
1032 if(lift_wpn)
9829 {
9830 1032 action=lifting; FFCore.setHeroAction(lifting);
9831 1032 }
9832 else
9833 {
9834 liftclk = 0;
9835 tliftclk = 0;
9836 }
9837 1032 }
9838
2/2
✓ Branch 0 taken 14157519 times.
✓ Branch 1 taken 10017 times.
14167536 else if(lift_wpn)
9839 {
9840 10017 handle_lift(false);
9841 10017 }
9842
9843
9844 // get user input or do other animation
9845 14168568 freeze_guys=false; // reset this flag, set it again if holding
9846
9847
14/16
✓ Branch 0 taken 14049634 times.
✓ Branch 1 taken 118934 times.
✓ Branch 2 taken 14023322 times.
✓ Branch 3 taken 26312 times.
✓ Branch 4 taken 14022150 times.
✓ Branch 5 taken 1172 times.
✓ Branch 6 taken 14021499 times.
✓ Branch 7 taken 651 times.
✓ Branch 8 taken 14021499 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 14021499 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 13998246 times.
✓ Branch 13 taken 23253 times.
✓ Branch 14 taken 13998130 times.
✓ Branch 15 taken 116 times.
14168568 if(action != landhold1 && action != landhold2 && action != waterhold1 && action != waterhold2 && action != sidewaterhold1 && action != sidewaterhold2 && fairyclk==0 && holdclk>0)
9848 {
9849 116 holdclk=0;
9850 116 }
9851
9852 14168568 active_shield_id = refreshActiveShield();
9853 14168568 bool sh = active_shield_id > -1;
9854 14168568 itemdata const& shield = itemsbuf[active_shield_id];
9855 //Handle direction forcing. This runs every frame so that scripts can interact with dir still.
9856 14168568 shield_forcedir = -1;
9857
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14168568 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14168568 if(sh && action != rafting && (shield.flags & item_flag11)) //Lock Dir
9858 {
9859 shield_forcedir = dir;
9860 }
9861
1/2
✓ Branch 0 taken 14168568 times.
✗ Branch 1 not taken.
14168568 if(sh != shield_active) //Toggle active shield on/off
9862 {
9863 shield_active = sh;
9864 if(sh) //Toggle active shield on
9865 {
9866 sfx(shield.usesound2); //'Activate' sfx
9867 }
9868 }
9869
9870 14168568 bool isthissolid = false;
9871
12/12
✓ Branch 0 taken 134909 times.
✓ Branch 1 taken 1823 times.
✓ Branch 2 taken 6144 times.
✓ Branch 3 taken 310942 times.
✓ Branch 4 taken 3887 times.
✓ Branch 5 taken 145246 times.
✓ Branch 6 taken 13427727 times.
✓ Branch 7 taken 102403 times.
✓ Branch 8 taken 3780 times.
✓ Branch 9 taken 14081 times.
✓ Branch 10 taken 16594 times.
✓ Branch 11 taken 1032 times.
14168568 switch(action)
9872 {
9873 case gothit:
9874
2/2
✓ Branch 0 taken 100110 times.
✓ Branch 1 taken 2293 times.
102403 if(attackclk)
9875
2/2
✓ Branch 0 taken 1986 times.
✓ Branch 1 taken 307 times.
2600 if(!doattack())
9876 {
9877 307 attackclk=spins=0;
9878 307 tapping=false;
9879 307 }
9880
9881 102403 break;
9882
9883 case drowning:
9884 case lavadrowning:
9885 case sidedrowning:
9886 {
9887 6144 herostep(); // maybe this line should be elsewhere?
9888
9889 //!DROWN
9890 // Helpful comment to find drowning -Dimi
9891
9892 6144 drop_liftwpn();
9893
2/2
✓ Branch 0 taken 6048 times.
✓ Branch 1 taken 96 times.
6144 if(--drownclk==0)
9894 {
9895 96 action=none; FFCore.setHeroAction(none);
9896
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 int32_t water = drownCombo ? drownCombo : iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9897
9898 96 std::vector<int32_t> &ev = FFCore.eventData;
9899 96 ev.clear();
9900 96 ev.push_back(water*10000);
9901
9902 96 throwGenScriptEvent(GENSCR_EVENT_PLAYER_DROWN);
9903 96 water = ev[0]/10000;
9904 96 newcombo const& watercmb = combobuf[water];
9905
9906 96 int32_t damage = 4;
9907
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 28 times.
96 if (watercmb.type == cWATER)
9908 68 damage = watercmb.attributes[0]/10000L;
9909 28 else water = 0;
9910
9911
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96 if(cheat_superman && damage > 0)
9912 damage = 0;
9913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(damage)
9914 96 game->set_life(vbound(game->get_life()-damage,0, game->get_maxlife()));
9915 96 drownCombo = 0;
9916 96 go_respawn_point();
9917 96 hclk=48;
9918 96 }
9919
9920 6144 break;
9921 }
9922 case falling:
9923 {
9924 3780 herostep();
9925 3780 pitfall();
9926 3780 break;
9927 }
9928 case freeze:
9929 case sideswimfreeze:
9930 case scrolling:
9931 310942 break;
9932
9933 case casting:
9934 case sideswimcasting:
9935 {
9936
2/2
✓ Branch 0 taken 3878 times.
✓ Branch 1 taken 9 times.
3887 if(magicitem==-1)
9937 {
9938 9 action=none; FFCore.setHeroAction(none);
9939 9 }
9940
9941 3887 break;
9942 }
9943 case landhold1:
9944 case landhold2:
9945 {
9946
2/2
✓ Branch 0 taken 1212 times.
✓ Branch 1 taken 144034 times.
145246 if(--holdclk <= 0)
9947 {
9948 //restart music
9949
4/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 1128 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 35 times.
1212 if(get_qr(qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9950 35 playLevelMusic();
9951
9952 1212 action=none; FFCore.setHeroAction(none);
9953 1212 post_item_collect();
9954 1212 }
9955 else
9956 144034 freeze_guys=true;
9957
9958 145246 break;
9959 }
9960 case waterhold1:
9961 case waterhold2:
9962 case sidewaterhold1:
9963 case sidewaterhold2:
9964 {
9965 1823 diveclk=0;
9966
9967
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1807 times.
1823 if(--holdclk <= 0)
9968 {
9969 //restart music
9970
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if(get_qr(qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9971 playLevelMusic();
9972
9973 16 SetSwim();
9974 16 post_item_collect();
9975 16 }
9976 else
9977 1807 freeze_guys=true;
9978
9979 1823 break;
9980 }
9981 case hopping:
9982 {
9983
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 14068 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
14081 if(DRIEDLAKE)
9984 {
9985 action=none; FFCore.setHeroAction(none);
9986 hopclk = 0;
9987 diveclk = 0;
9988 break;
9989 }
9990
9991 14081 do_hopping();
9992 14081 break;
9993 }
9994 case inwind:
9995 {
9996 16594 int32_t i=Lwpns.idFirst(wWind);
9997
9998
2/2
✓ Branch 0 taken 16371 times.
✓ Branch 1 taken 223 times.
16594 if(i<0)
9999 {
10000 223 bool exit=false;
10001
10002
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 112 times.
223 if(whirlwind==255)
10003 {
10004 111 exit=true;
10005 111 }
10006
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
112 else if(y<=0 && dir==up) y=-1;
10007
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
112 else if(y>=160 && dir==down) y=161;
10008
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
112 else if(x<=0 && dir==left) x=-1;
10009
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
112 else if(x>=240 && dir==right) x=241;
10010 else exit=true;
10011
10012
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 111 times.
223 if(exit)
10013 {
10014 111 action=none; FFCore.setHeroAction(none);
10015 111 xofs=0;
10016 111 whirlwind=0;
10017 111 lstep=0;
10018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if ( dontdraw < 2 ) dontdraw=0;
10019 111 set_respawn_point();
10020 111 }
10021 223 }
10022 /*
10023 else if (((weapon*)Lwpns.spr(i))->dead==1)
10024 {
10025 whirlwind=255;
10026 }
10027 */
10028 else
10029 {
10030 16371 x=Lwpns.spr(i)->x;
10031 16371 y=Lwpns.spr(i)->y;
10032 16371 dir=Lwpns.spr(i)->dir;
10033 }
10034 }
10035 16594 break;
10036 case lifting:
10037 1032 handle_lift();
10038 1032 break;
10039
10040 case sideswimming:
10041 case sideswimattacking:
10042 case sideswimhit:
10043 case swimhit:
10044 case swimming:
10045 {
10046
3/4
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 134743 times.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
134909 if(DRIEDLAKE)
10047 {
10048 action=none; FFCore.setHeroAction(none);
10049 hopclk=0;
10050 break;
10051 }
10052
10053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134909 times.
134909 bool shouldbreak = (action == sideswimhit || action == swimhit); //!DIMITODO: "Can walk while hurt" compat needs to be added here.
10054
10055
4/4
✓ Branch 0 taken 67399 times.
✓ Branch 1 taken 67510 times.
✓ Branch 2 taken 626 times.
✓ Branch 3 taken 66773 times.
134909 if((frame&1) && !shouldbreak)
10056 66773 herostep();
10057
10058
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 134909 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 134909 times.
✓ Branch 4 taken 10279 times.
✓ Branch 5 taken 124630 times.
145411 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
10059
4/6
✓ Branch 0 taken 124407 times.
✓ Branch 1 taken 10502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10502 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10502 times.
134909 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
10060
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 10493 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10493 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10493 times.
10502 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
10061
4/6
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 10279 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10279 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10279 times.
135123 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
10062
4/4
✓ Branch 0 taken 126779 times.
✓ Branch 1 taken 8130 times.
✓ Branch 2 taken 126779 times.
✓ Branch 3 taken 8130 times.
134909 if ((get_qr(qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) //Since hopping won't be set with this on, something needs to kick Hero out of water...
10063 {
10064
4/4
✓ Branch 0 taken 8082 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 8027 times.
✓ Branch 3 taken 4 times.
16161 if(!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+9), currmap, currscr, -1, x.getInt()+4,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+15), currmap, currscr, -1, x.getInt()+4,y.getInt()+15, true, false)
10065
4/4
✓ Branch 0 taken 8058 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 8031 times.
✓ Branch 3 taken 27 times.
8082 || !iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+9), currmap, currscr, -1, x.getInt()+11,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+15), currmap, currscr, -1, x.getInt()+11,y.getInt()+15, true, false))
10066 {
10067 103 hopclk=0;
10068 103 diveclk=0;
10069
2/4
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 103 times.
103 if (action != sideswimattacking && action != attacking) {action=none; FFCore.setHeroAction(none);}
10070 else {action=attacking; FFCore.setHeroAction(attacking);}
10071 103 hopdir=-1;
10072 103 }
10073 8130 }
10074
2/2
✓ Branch 0 taken 1259 times.
✓ Branch 1 taken 133650 times.
134909 if (shouldbreak) break;
10075
4/6
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 133547 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 103 times.
133650 if (action == swimming || action == sideswimming || action == sideswimattacking)
10076 {
10077 133547 int32_t watercheck = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
10078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133547 times.
133547 if (combobuf[watercheck].usrflags&cflag2)
10079 {
10080 if (current_item(combobuf[watercheck].attribytes[2]) < combobuf[watercheck].attribytes[3])
10081 {
10082 onpassivedmg = true;
10083 if (damageovertimeclk == 0)
10084 {
10085 int32_t curhp = game->get_life();
10086 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
10087 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
10088 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
10089 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
10090 {
10091 hclk = 48;
10092 hitdir = -1;
10093 if (IsSideSwim()) {action = sideswimhit; FFCore.setHeroAction(sideswimhit);}
10094 else {action = swimhit; FFCore.setHeroAction(swimhit);}
10095 }
10096 }
10097 if (combobuf[watercheck].attribytes[1] > 0)
10098 {
10099 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
10100 else --damageovertimeclk;
10101 }
10102 else damageovertimeclk = 0;
10103 }
10104 else damageovertimeclk = 0;
10105 }
10106 133547 else damageovertimeclk = 0;
10107 //combobuf[watercheck].attributes[0]
10108 133547 }
10109
10110 133650 }
10111 [[fallthrough]];
10112 default:
10113 // call the main movement routine
10114
2/2
✓ Branch 0 taken 391624 times.
✓ Branch 1 taken 13169753 times.
13561377 if(get_qr(qr_NEW_HERO_MOVEMENT2))
10115 {
10116
2/2
✓ Branch 0 taken 37440 times.
✓ Branch 1 taken 354184 times.
391624 if(premove())
10117 354184 movehero();
10118 391624 }
10119 else
10120 {
10121 13169753 sliding = 0;
10122 13169753 moveheroOld();
10123 }
10124 13561377 }
10125
11/14
✓ Branch 0 taken 255615 times.
✓ Branch 1 taken 13912953 times.
✓ Branch 2 taken 1281 times.
✓ Branch 3 taken 254334 times.
✓ Branch 4 taken 1281 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1251 times.
✓ Branch 7 taken 30 times.
✓ Branch 8 taken 1224 times.
✓ Branch 9 taken 27 times.
✓ Branch 10 taken 1224 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1224 times.
14168568 if (isSideViewHero() && slopeid && hoverclk < 1 && !inair && fall == 0 && !IsSideSwim() && justmoved <= 0)
10126 {
10127
2/2
✓ Branch 0 taken 891 times.
✓ Branch 1 taken 333 times.
1224 if (!on_sideview_solid_oldpos(this, false, 0))
10128 {
10129 333 zfix dy = 0;
10130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 for (zfix q = 0; q <= 4; ++q)
10131 {
10132
2/2
✓ Branch 0 taken 759 times.
✓ Branch 1 taken 333 times.
1092 if (on_sideview_solid_oldpos(this, false, 0, 0, q))
10133 {
10134 333 dy = q;
10135 333 break;
10136 }
10137 759 }
10138
3/6
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 333 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 333 times.
✗ Branch 5 not taken.
5451 dy = binary_search_zfix(0, dy, [&](zfix val, zfix& retval)
10139 {
10140
2/2
✓ Branch 0 taken 1521 times.
✓ Branch 1 taken 3597 times.
5118 if (on_sideview_solid_oldpos(this, false, 0, 0, val))
10141 {
10142 1521 retval = val;
10143 1521 return BSEARCH_CONTINUE_TOWARD0;
10144 }
10145 3597 else return BSEARCH_CONTINUE_AWAY0;
10146 5118 });
10147
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 165 times.
333 if (dy) push_move(0, dy);
10148 333 }
10149 1224 }
10150
10151
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14168568 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14168568 if(shield_forcedir > -1 && action != rafting)
10152 dir = shield_forcedir;
10153
10154
10155 // check for ladder removal
10156
2/2
✓ Branch 0 taken 4421102 times.
✓ Branch 1 taken 9747466 times.
14168568 if(diagonalMovement)
10157 {
10158
2/2
✓ Branch 0 taken 4412441 times.
✓ Branch 1 taken 8661 times.
4421102 if(ladderx+laddery)
10159 {
10160
2/2
✓ Branch 0 taken 3309 times.
✓ Branch 1 taken 5352 times.
8661 if(ladderdir<=down)
10161 {
10162
10/10
✓ Branch 0 taken 2266 times.
✓ Branch 1 taken 1043 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 3241 times.
✓ Branch 4 taken 2229 times.
✓ Branch 5 taken 1012 times.
✓ Branch 6 taken 3210 times.
✓ Branch 7 taken 31 times.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 3205 times.
3309 if((laddery-y.getInt()>=(16+(ladderstart==dir?ladderstart==down?1:0:0))) || (laddery-y.getInt()<=(-16-(ladderstart==dir?ladderstart==up?1:0:0))) || (abs(ladderx-x.getInt())>8))
10163 {
10164 104 reset_ladder();
10165 104 }
10166 3309 }
10167 else
10168 {
10169
10/10
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5347 times.
✓ Branch 2 taken 4277 times.
✓ Branch 3 taken 1070 times.
✓ Branch 4 taken 64 times.
✓ Branch 5 taken 5283 times.
✓ Branch 6 taken 4245 times.
✓ Branch 7 taken 1038 times.
✓ Branch 8 taken 89 times.
✓ Branch 9 taken 5194 times.
5352 if((abs(laddery-y.getInt())>8) || (ladderx-x.getInt()>=(16+(ladderstart==dir?ladderstart==right?1:0:0))) || (ladderx-x.getInt()<=(-16-(ladderstart==dir?ladderstart==left?1:0:0))))
10170 {
10171 158 reset_ladder();
10172 158 }
10173 }
10174 8661 }
10175 4421102 }
10176 else
10177 {
10178
4/4
✓ Branch 0 taken 334163 times.
✓ Branch 1 taken 9413303 times.
✓ Branch 2 taken 194300 times.
✓ Branch 3 taken 139863 times.
9747466 if((abs(laddery-y.getInt())>=16) || (abs(ladderx-x.getInt())>=16))
10179 {
10180 9607603 reset_ladder();
10181 9607603 }
10182 }
10183
10184
2/2
✓ Branch 0 taken 13692542 times.
✓ Branch 1 taken 476026 times.
14168568 if(!get_qr(qr_OLD_RESPAWN_POINTS)) //needs to happen after ladder removal so the respawn point is set when laddering over multiple 1 tile gaps.
10185 476026 set_respawn_point(false); //Keep the 'last safe location' updated!
10186
10187
2/2
✓ Branch 0 taken 3160 times.
✓ Branch 1 taken 14165408 times.
14168568 if(ilswim)
10188 3160 landswim++;
10189 14165408 else landswim=0;
10190
10191
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 14168396 times.
14168568 if(hopclk!=0xFF) ilswim=false;
10192
10193
4/4
✓ Branch 0 taken 35966 times.
✓ Branch 1 taken 14132602 times.
✓ Branch 2 taken 1757 times.
✓ Branch 3 taken 34209 times.
14168568 if((!loaded_guys) && (frame - newscr_clk >= 1))
10194 {
10195
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 34192 times.
34209 if(tmpscr->room==rGANON)
10196 {
10197 17 ganon_intro();
10198 17 }
10199 else
10200 {
10201 34192 loadguys();
10202 }
10203 34209 }
10204
10205
2/2
✓ Branch 0 taken 37968 times.
✓ Branch 1 taken 14130600 times.
14168568 if(frame - newscr_clk >= 2)
10206 {
10207 14130600 loadenemies();
10208 14130600 }
10209
10210 // check lots of other things
10211 14168568 checkscroll();
10212
10213
7/8
✓ Branch 0 taken 14152086 times.
✓ Branch 1 taken 16482 times.
✓ Branch 2 taken 14146290 times.
✓ Branch 3 taken 5796 times.
✓ Branch 4 taken 14146290 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 253 times.
✓ Branch 7 taken 14146037 times.
14168568 if(action!=inwind && action!=drowning && action != sidedrowning && action!=lavadrowning)
10214 {
10215 14146037 checkspecial();
10216 14146037 checkitems();
10217 14146037 checklocked(); //This has issues if Hero's action is WALKING, in 8-way moveent.
10218
2/2
✓ Branch 0 taken 564912 times.
✓ Branch 1 taken 13581125 times.
14146037 if(get_qr(qr_OLD_LOCKBLOCK_COLLISION))
10219 {
10220 13581125 oldchecklockblock();
10221 13581125 oldcheckbosslockblock();
10222 13581125 }
10223
2/2
✓ Branch 0 taken 1001597 times.
✓ Branch 1 taken 13144440 times.
14146037 if(get_qr(qr_OLD_CHEST_COLLISION))
10224 {
10225 13144440 oldcheckchest(cCHEST);
10226 13144440 oldcheckchest(cLOCKEDCHEST);
10227 13144440 oldcheckchest(cBOSSCHEST);
10228 13144440 }
10229 14146037 checkpushblock();
10230 14146037 checkswordtap();
10231
10232
2/2
✓ Branch 0 taken 14098762 times.
✓ Branch 1 taken 47275 times.
14146037 if(hookshot_frozen==false)
10233 {
10234 14098762 checkspecial2(&lsave);
10235 14098762 }
10236
10237
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 14146027 times.
14146037 if(action==won)
10238 {
10239 10 return true;
10240 }
10241 14146027 }
10242
10243 // Somehow Hero was displaced from the fairy flag...
10244
3/6
✓ Branch 0 taken 23254 times.
✓ Branch 1 taken 14145304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23254 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14168558 if(fairyclk && action != freeze && action != sideswimfreeze)
10245 {
10246 fairyclk = holdclk = refill_why = 0;
10247 }
10248
10249
4/4
✓ Branch 0 taken 14168557 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 14086697 times.
✓ Branch 3 taken 81860 times.
14168558 if((!activated_timed_warp) && (tmpscr->timedwarptics>0))
10250 {
10251 81860 tmpscr->timedwarptics--;
10252
10253
2/2
✓ Branch 0 taken 493 times.
✓ Branch 1 taken 81367 times.
81860 if(tmpscr->timedwarptics==0)
10254 {
10255 493 activated_timed_warp=true;
10256
10257
2/2
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 121 times.
493 if(tmpscr->flags4 & fTIMEDDIRECT)
10258 {
10259 121 didpit=true;
10260 121 pitx=x;
10261 121 pity=y;
10262 121 }
10263
10264 493 int32_t index2 = 0;
10265
10266
1/2
✓ Branch 0 taken 493 times.
✗ Branch 1 not taken.
493 if(tmpscr->flags5 & fRANDOMTIMEDWARP) index2=zc_oldrand()%4;
10267
10268 493 sdir = dir;
10269 493 dowarp(1,index2);
10270 493 }
10271 81860 }
10272
10273 14168558 bool awarp = false;
10274 //!DIMI: Global Combo Effects (AUTO STUFF)
10275
2/2
✓ Branch 0 taken 14168403 times.
✓ Branch 1 taken 2493648437 times.
2507816840 for(int32_t i=0; i<176; ++i)
10276 {
10277
2/2
✓ Branch 0 taken 83473984 times.
✓ Branch 1 taken 10225015235 times.
10308489219 for(int32_t layer=0; layer<7; ++layer)
10278 {
10279
2/2
✓ Branch 0 taken 7731366798 times.
✓ Branch 1 taken 2493648437 times.
10225015235 int32_t cid = ( layer ) ? MAPCOMBOL(layer,COMBOX(i),COMBOY(i)) : MAPCOMBO(COMBOX(i),COMBOY(i));
10280 10225015235 newcombo const& cmb = combobuf[cid];
10281
10282
2/2
✓ Branch 0 taken 584317889 times.
✓ Branch 1 taken 9640697346 times.
10225015235 if(!get_qr(qr_AUTOCOMBO_ANY_LAYER))
10283 {
10284
2/2
✓ Branch 0 taken 7230523048 times.
✓ Branch 1 taken 2410174298 times.
9640697346 if(layer > 2) break;
10285
4/4
✓ Branch 0 taken 2410174298 times.
✓ Branch 1 taken 4820348750 times.
✓ Branch 2 taken 46393952 times.
✓ Branch 3 taken 2363780346 times.
7230523048 if (layer == 1 && !get_qr(qr_AUTOCOMBO_LAYER_1)) continue;
10286
4/4
✓ Branch 0 taken 2410174298 times.
✓ Branch 1 taken 2456568404 times.
✓ Branch 2 taken 46393952 times.
✓ Branch 3 taken 2363780346 times.
4866742702 if (layer == 2 && !get_qr(qr_AUTOCOMBO_LAYER_2)) continue;
10287 2502962356 }
10288 3087280245 int32_t ind=0;
10289
10290 //AUTOMATIC TRIGGER CODE
10291
2/2
✓ Branch 0 taken 3086350465 times.
✓ Branch 1 taken 929780 times.
3087280245 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
10292 {
10293 929780 do_trigger_combo(layer, i);
10294 929780 }
10295
10296 //AUTO WARP CODE
10297
2/2
✓ Branch 0 taken 19475 times.
✓ Branch 1 taken 3087260770 times.
3087280245 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
10298 {
10299
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 3087260681 times.
3087260770 if(cmb.type==cAWARPA)
10300 {
10301 89 awarp=true;
10302 89 ind=0;
10303 89 }
10304
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 3087260618 times.
3087260681 else if(cmb.type==cAWARPB)
10305 {
10306 63 awarp=true;
10307 63 ind=1;
10308 63 }
10309
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3087260615 times.
3087260618 else if(cmb.type==cAWARPC)
10310 {
10311 3 awarp=true;
10312 3 ind=2;
10313 3 }
10314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3087260615 times.
3087260615 else if(cmb.type==cAWARPD)
10315 {
10316 awarp=true;
10317 ind=3;
10318 }
10319
1/2
✓ Branch 0 taken 3087260615 times.
✗ Branch 1 not taken.
3087260615 else if(cmb.type==cAWARPR)
10320 {
10321 awarp=true;
10322 ind=zc_oldrand()%4;
10323 }
10324 3087260770 }
10325
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 3087280090 times.
3087280245 if(awarp)
10326 {
10327
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 67 times.
155 if(tmpscr->flags5&fDIRECTAWARP)
10328 {
10329 67 didpit=true;
10330 67 pitx=x;
10331 67 pity=y;
10332 67 }
10333
10334 155 sdir = dir;
10335 155 dowarp(1,ind);
10336 155 break;
10337 }
10338 3087280090 }
10339
2/2
✓ Branch 0 taken 2493648282 times.
✓ Branch 1 taken 155 times.
2493648437 if(awarp) break;
10340 2493648282 }
10341
10342 14168558 awarp=false;
10343
10344 14168558 word c = tmpscr->numFFC();
10345
2/2
✓ Branch 0 taken 14168501 times.
✓ Branch 1 taken 424280999 times.
438449500 for(word i=0; i<c; i++)
10346 {
10347 424280999 int32_t ind=0;
10348
10349 424280999 newcombo const& cmb = combobuf[tmpscr->ffcs[i].data];
10350
10351
2/2
✓ Branch 0 taken 424269572 times.
✓ Branch 1 taken 11427 times.
424280999 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
10352 {
10353 11427 do_trigger_combo_ffc(i);
10354 11427 }
10355
10356
2/2
✓ Branch 0 taken 3908 times.
✓ Branch 1 taken 424277091 times.
424280999 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
10357 {
10358
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 424277072 times.
424277091 if(cmb.type==cAWARPA)
10359 {
10360 19 awarp=true;
10361 19 ind=0;
10362 19 }
10363
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 424277039 times.
424277072 else if(cmb.type==cAWARPB)
10364 {
10365 33 awarp=true;
10366 33 ind=1;
10367 33 }
10368
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 424277037 times.
424277039 else if(cmb.type==cAWARPC)
10369 {
10370 2 awarp=true;
10371 2 ind=2;
10372 2 }
10373
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 424277034 times.
424277037 else if(cmb.type==cAWARPD)
10374 {
10375 3 awarp=true;
10376 3 ind=3;
10377 3 }
10378
1/2
✓ Branch 0 taken 424277034 times.
✗ Branch 1 not taken.
424277034 else if(cmb.type==cAWARPR)
10379 {
10380 awarp=true;
10381 ind=zc_oldrand()%4;
10382 }
10383 424277091 }
10384
10385
2/2
✓ Branch 0 taken 424280942 times.
✓ Branch 1 taken 57 times.
424280999 if(awarp)
10386 {
10387
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(tmpscr->flags5&fDIRECTAWARP)
10388 {
10389 didpit=true;
10390 pitx=x;
10391 pity=y;
10392 }
10393
10394 57 sdir = dir;
10395 57 dowarp(1,ind);
10396 57 break;
10397 }
10398 424280942 }
10399 14168558 zfix dx, dy;
10400
7/8
✓ Branch 0 taken 255616 times.
✓ Branch 1 taken 13912942 times.
✓ Branch 2 taken 128062 times.
✓ Branch 3 taken 127554 times.
✓ Branch 4 taken 1119 times.
✓ Branch 5 taken 126943 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1119 times.
14168558 if (sideview_mode() && !on_sideview_solid_oldpos(this, false, 1) && on_sideview_solid_oldpos(this, false, 2) && !toogam)
10401 {
10402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if (slide_slope(this, dx, dy, slopeid))
10403 {
10404 1119 onplatid = 1;
10405
2/4
✓ Branch 0 taken 1119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1119 times.
1119 if (dx || dy) push_move(dx, dy);
10406 1119 }
10407 1119 }
10408
2/2
✓ Branch 0 taken 14167301 times.
✓ Branch 1 taken 1257 times.
14168558 if (onplatid <= 0) slopeid = 0;
10409 1257 else --onplatid;
10410
2/2
✓ Branch 0 taken 11260581 times.
✓ Branch 1 taken 2907977 times.
14168558 bool onplatform = (on_sideview_solid_oldpos(this, false, 1) && !Up());
10411
5/6
✓ Branch 0 taken 2909 times.
✓ Branch 1 taken 14168554 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2909 times.
✓ Branch 4 taken 2905 times.
✓ Branch 5 taken 14168558 times.
14171463 for (auto q = 0; (check_slope(this, true) && !toogam) && q < 2; ++q)
10412 {
10413 2905 dx = 0;
10414 2905 dy = 0;
10415
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2905 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2905 times.
2905 if (check_slope(this, true) && !toogam)
10416 {
10417 2905 slope_info const& s = get_slope(this, true).get_info();
10418 2905 bool staircheck = false;
10419
3/4
✓ Branch 0 taken 2686 times.
✓ Branch 1 taken 219 times.
✓ Branch 2 taken 2686 times.
✗ Branch 3 not taken.
2905 if (s.slope() != slopeid && slopeid) staircheck = true;
10420
2/2
✓ Branch 0 taken 2839 times.
✓ Branch 1 taken 66 times.
2905 if (onplatform) staircheck = true;
10421 2905 slope_push_int(s, this, dx, dy, staircheck, platformfell2);
10422
10423
4/4
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 2634 times.
✓ Branch 2 taken 270 times.
✓ Branch 3 taken 1 times.
2905 if (dx || dy)
10424 {
10425 2904 int32_t pushret = push_move(dx,dy);
10426
2/2
✓ Branch 0 taken 2886 times.
✓ Branch 1 taken 18 times.
2904 onplatform = (on_sideview_solid_oldpos(this, false, 1) && !Up());
10427
3/4
✓ Branch 0 taken 2685 times.
✓ Branch 1 taken 219 times.
✓ Branch 2 taken 2685 times.
✗ Branch 3 not taken.
2904 if (s.slope() != slopeid && slopeid) staircheck = true;
10428
2/2
✓ Branch 0 taken 2886 times.
✓ Branch 1 taken 18 times.
2904 if (onplatform) staircheck = true;
10429
4/4
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 2628 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 219 times.
2904 if(sideview_mode() && slopeid)
10430 219 onplatid = 0;
10431
1/2
✓ Branch 0 taken 2904 times.
✗ Branch 1 not taken.
2904 if (pushret == 1)
10432 {
10433 dx = -1;
10434 dy = 0;
10435 slope_push_int(s, this, dx, dy, staircheck);
10436 push_move(0,dy);
10437 }
10438
2/2
✓ Branch 0 taken 2903 times.
✓ Branch 1 taken 1 times.
2904 if (pushret == 2)
10439 {
10440 1 dx = 0;
10441 1 dy = -1;
10442 1 slope_push_int(s, this, dx, dy, staircheck);
10443 1 push_move(dx,0);
10444 1 }
10445 2904 }
10446 2905 }
10447 2905 }
10448
10449
2/2
✓ Branch 0 taken 14168352 times.
✓ Branch 1 taken 206 times.
14168558 if(ffwarp)
10450 {
10451
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 127 times.
206 if(ffpit)
10452 {
10453 127 ffpit=false;
10454 127 didpit=true;
10455 127 pitx=x;
10456 127 pity=y;
10457 127 }
10458
10459 206 ffwarp=false;
10460 206 dowarp(1,0);
10461 206 }
10462
10463 //Hero->WarpEx
10464
2/2
✓ Branch 0 taken 14168454 times.
✓ Branch 1 taken 104 times.
14168558 if ( FFCore.warpex[wexActive] )
10465 {
10466 if(DEVLOGGING) zprint("Running warpex from hero.cpp\n");
10467 104 FFCore.warpex[wexActive] = 0;
10468 104 int32_t temp_warpex[wexActive] = {0}; //to hold the values as we clear the FFCore array. -Z
10469
2/2
✓ Branch 0 taken 936 times.
✓ Branch 1 taken 104 times.
1040 for ( int32_t q = 0; q < wexActive; q++ )
10470 {
10471 936 temp_warpex[q] = FFCore.warpex[q];
10472 936 FFCore.warpex[q] = 0;
10473 936 }
10474 208 FFCore.warp_player( temp_warpex[wexType], temp_warpex[wexDMap], temp_warpex[wexScreen], temp_warpex[wexX],
10475 104 temp_warpex[wexY], temp_warpex[wexEffect], temp_warpex[wexSound], temp_warpex[wexFlags], temp_warpex[wexDir]);
10476 104 }
10477
10478
4/4
✓ Branch 0 taken 18640 times.
✓ Branch 1 taken 14149918 times.
✓ Branch 2 taken 28107 times.
✓ Branch 3 taken 32911 times.
14168558 if(z == 0 || !get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
10479 {
10480 // walk through bombed doors and fake walls
10481 14182829 bool walk=false;
10482 14182829 int32_t dtype=dBOMBED;
10483
10484
2/2
✓ Branch 0 taken 13825266 times.
✓ Branch 1 taken 291741 times.
14182829 if(pushing>=24) dtype=dWALK;
10485
10486
16/18
✓ Branch 0 taken 6269928 times.
✓ Branch 1 taken 7847079 times.
✓ Branch 2 taken 6133322 times.
✓ Branch 3 taken 136606 times.
✓ Branch 4 taken 6133322 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6121981 times.
✓ Branch 7 taken 11341 times.
✓ Branch 8 taken 6118560 times.
✓ Branch 9 taken 3421 times.
✓ Branch 10 taken 6111353 times.
✓ Branch 11 taken 7207 times.
✓ Branch 12 taken 6097641 times.
✓ Branch 13 taken 13712 times.
✓ Branch 14 taken 6097641 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 93104 times.
✓ Branch 17 taken 6190745 times.
14117007 if(isdungeon() && action!=freeze && action != sideswimfreeze && loaded_guys && !inlikelike && !diveclk && action!=rafting && !lstunclock && !is_conveyor_stunned)
10487 {
10488
12/14
✓ Branch 0 taken 129000 times.
✓ Branch 1 taken 6061745 times.
✓ Branch 2 taken 1018716 times.
✓ Branch 3 taken 5043029 times.
✓ Branch 4 taken 1013612 times.
✓ Branch 5 taken 5104 times.
✓ Branch 6 taken 1013612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1013612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 946941 times.
✓ Branch 11 taken 941837 times.
✓ Branch 12 taken 66446 times.
✓ Branch 13 taken 225 times.
6190745 if(((dtype==dBOMBED)?DrunkUp():dir==up) && ((diagonalMovement||NO_GRIDLOCK)?x.getInt()>112&&x.getInt()<128:x.getInt()==120) && y<=32 && tmpscr->door[0]==dtype)
10489 {
10490 225 walk=true;
10491 225 dir=up;
10492 225 }
10493
10494
12/14
✓ Branch 0 taken 129000 times.
✓ Branch 1 taken 6051537 times.
✓ Branch 2 taken 733888 times.
✓ Branch 3 taken 5317649 times.
✓ Branch 4 taken 858719 times.
✓ Branch 5 taken 4169 times.
✓ Branch 6 taken 858719 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 858719 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 815398 times.
✓ Branch 11 taken 811229 times.
✓ Branch 12 taken 43105 times.
✓ Branch 13 taken 216 times.
6180537 if(((dtype==dBOMBED)?DrunkDown():dir==down) && ((diagonalMovement||NO_GRIDLOCK)?x.getInt()>112&&x.getInt()<128:x.getInt()==120) && y>=128 && tmpscr->door[1]==dtype)
10495 {
10496 216 walk=true;
10497 216 dir=down;
10498 216 }
10499
10500
12/14
✓ Branch 0 taken 129000 times.
✓ Branch 1 taken 6043199 times.
✓ Branch 2 taken 47331 times.
✓ Branch 3 taken 5995868 times.
✓ Branch 4 taken 101764 times.
✓ Branch 5 taken 215 times.
✓ Branch 6 taken 101764 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 101764 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 103 times.
✓ Branch 11 taken 112 times.
✓ Branch 12 taken 101589 times.
✓ Branch 13 taken 101486 times.
6172199 if(((dtype==dBOMBED)?DrunkLeft():dir==left) && x<=32 && ((diagonalMovement||NO_GRIDLOCK)?y.getInt()>72&&y.getInt()<88:y.getInt()==80) && tmpscr->door[2]==dtype)
10501 {
10502 175 walk=true;
10503 175 dir=left;
10504 175 }
10505
10506
12/14
✓ Branch 0 taken 5968641 times.
✓ Branch 1 taken 129000 times.
✓ Branch 2 taken 42209 times.
✓ Branch 3 taken 5926432 times.
✓ Branch 4 taken 122261 times.
✓ Branch 5 taken 90 times.
✓ Branch 6 taken 122261 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 122261 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 56 times.
✓ Branch 11 taken 34 times.
✓ Branch 12 taken 122066 times.
✓ Branch 13 taken 122010 times.
6097641 if(((dtype==dBOMBED)?DrunkRight():dir==right) && x>=208 && ((diagonalMovement||NO_GRIDLOCK)?y.getInt()>72&&y.getInt()<88:y.getInt()==80) && tmpscr->door[3]==dtype)
10507 {
10508 195 walk=true;
10509 195 dir=right;
10510 195 }
10511 6048671 }
10512
10513
2/2
✓ Branch 0 taken 14160330 times.
✓ Branch 1 taken 811 times.
14161141 if(walk)
10514 {
10515 811 hclk=0;
10516 811 drawguys=false;
10517
10518
2/2
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 195 times.
811 if(dtype==dWALK)
10519 {
10520 195 sfx(tmpscr->secretsfx);
10521
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 if(!get_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE))
10522 set_doorstate(dir);
10523 195 }
10524
10525 811 action=none; FFCore.setHeroAction(none);
10526 811 attackclk = 0;
10527 811 stepforward(29, true);
10528 811 action=scrolling; FFCore.setHeroAction(scrolling);
10529 811 pushing=false;
10530 811 }
10531 14161141 }
10532
10533
5/6
✓ Branch 0 taken 337886 times.
✓ Branch 1 taken 13851362 times.
✓ Branch 2 taken 335393 times.
✓ Branch 3 taken 2493 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 335393 times.
14189248 if( game->get_life() <= (game->get_hp_per_heart()) && !(game->get_maxlife() <= (game->get_hp_per_heart())) && (heart_beep_timer > -3))
10534 {
10535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 335393 times.
335393 if(heart_beep)
10536 {
10537 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
10538 }
10539 else
10540 {
10541
2/2
✓ Branch 0 taken 334866 times.
✓ Branch 1 taken 527 times.
335393 if ( heart_beep_timer == -1 )
10542 {
10543 527 heart_beep_timer = 70;
10544 527 }
10545
10546
2/2
✓ Branch 0 taken 29603 times.
✓ Branch 1 taken 305790 times.
335393 if ( heart_beep_timer > 0 )
10547 {
10548 29603 --heart_beep_timer;
10549 29603 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
10550 29603 }
10551 else
10552 {
10553 305790 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
10554 }
10555 }
10556 335393 }
10557 else
10558 {
10559
2/2
✓ Branch 0 taken 25687 times.
✓ Branch 1 taken 13833164 times.
13853855 if ( heart_beep_timer > -2 )
10560 {
10561 13833164 heart_beep_timer = -1;
10562 13833164 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
10563 13833164 }
10564 }
10565
10566
2/2
✓ Branch 0 taken 14192827 times.
✓ Branch 1 taken 1417 times.
14194244 if(rSbtn())
10567 {
10568 1417 int32_t tmp_subscr_clk = frame;
10569
10570 1417 int32_t save_type = 0;
10571
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 1409 times.
✗ Branch 3 not taken.
1417 switch(lsave)
10572 {
10573 case 0:
10574 {
10575
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 1368 times.
1409 if( FFCore.runScriptedActiveSusbcreen() )
10576 {
10577 41 break;
10578 }
10579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
1368 else if ( !stopSubscreenFalling() )
10580 {
10581 1368 conveyclk=3;
10582 1368 dosubscr();
10583 1368 newscr_clk += frame - tmp_subscr_clk;
10584 1368 }
10585 1368 break;
10586 }
10587
10588
10589 case 2:
10590 save_type = 1;
10591 [[fallthrough]];
10592 case 1:
10593
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(last_savepoint_id)
10594 7 trigger_save(combobuf[last_savepoint_id]);
10595 else save_game((tmpscr->flags4&fSAVEROOM) != 0, save_type); //sanity?
10596 7 break;
10597 }
10598 1417 }
10599
10600
2/2
✓ Branch 0 taken 808040 times.
✓ Branch 1 taken 13386202 times.
14194242 if (!checkstab() )
10601 {
10602 /*
10603 for(int32_t q=0; q<176; q++)
10604 {
10605 set_bit(screengrid,q,0);
10606 }
10607
10608 for(int32_t q=0; q<MAXFFCS; q++)
10609 set_bit(ffcgrid, q, 0);
10610 */
10611 13386202 }
10612
10613 14194242 check_conveyor();
10614 14194242 PhantomsCleanup();
10615 //Try to time the hammer pound so that Hero can;t change direction while it occurs.
10616
2/2
✓ Branch 0 taken 13990913 times.
✓ Branch 1 taken 203329 times.
14194242 if(attack==wHammer)
10617 {
10618
6/8
✓ Branch 0 taken 2170 times.
✓ Branch 1 taken 201159 times.
✓ Branch 2 taken 2170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 2165 times.
203329 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
10619 {
10620
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
✓ Branch 2 taken 508 times.
✓ Branch 3 taken 715 times.
✓ Branch 4 taken 601 times.
2165 switch(dir) //Hero's dir
10621 {
10622 case up:
10623
5/10
✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 341 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 341 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 341 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 341 times.
✗ Branch 9 not taken.
341 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
10624 341 break;
10625
10626 case down:
10627
5/10
✓ Branch 0 taken 508 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 508 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 508 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 508 times.
✗ Branch 9 not taken.
508 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
10628 508 break;
10629
10630 case left:
10631
5/10
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 715 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 715 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 715 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 715 times.
✗ Branch 9 not taken.
715 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
10632 715 break;
10633
10634 case right:
10635
5/10
✓ Branch 0 taken 601 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 601 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 601 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 601 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 601 times.
✗ Branch 9 not taken.
601 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
10636 601 break;
10637 }
10638
10639 2165 }
10640 203329 }
10641
10642 14194242 handleSpotlights();
10643
10644
1/2
✓ Branch 0 taken 14194242 times.
✗ Branch 1 not taken.
14194242 if(getOnSideviewLadder())
10645 {
10646 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
10647 {
10648 setOnSideviewLadder(false);
10649 }
10650 else if(CANFORCEFACEUP)
10651 {
10652 setDir(up);
10653 }
10654 }
10655
2/2
✓ Branch 0 taken 13936478 times.
✓ Branch 1 taken 257764 times.
14194242 if (justmoved > 0) --justmoved;
10656 14194242 return false;
10657 14195867 }
10658
10659 7679 bool HeroClass::push_pixel(zfix dx, zfix dy)
10660 {
10661 ASSERT(abs(dx) <= 1 && abs(dy) <= 1);
10662
3/4
✓ Branch 0 taken 3409 times.
✓ Branch 1 taken 4270 times.
✓ Branch 2 taken 3409 times.
✗ Branch 3 not taken.
7679 if(dx && dy)
10663 {
10664 bool r = push_pixel(0,dy);
10665 bool r2 = push_pixel(dx,0);
10666 return r && r2;
10667 }
10668
2/2
✓ Branch 0 taken 1568 times.
✓ Branch 1 taken 6111 times.
7679 if(dx < 0)
10669 {
10670
1/2
✓ Branch 0 taken 1568 times.
✗ Branch 1 not taken.
3136 if(!(solpush_walkflag(x+dx,y+(bigHitbox?0:8),1,this)
10671
1/2
✓ Branch 0 taken 1568 times.
✗ Branch 1 not taken.
1568 || solpush_walkflag(x+dx,y+8,1,this)
10672
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1568 times.
✓ Branch 2 taken 1387 times.
✓ Branch 3 taken 181 times.
1568 || (y.getInt()&7?solpush_walkflag(x+dx,y+16,1,this):0)))
10673 {
10674 1568 x += dx;
10675 1568 return true;
10676 }
10677 return false;
10678 }
10679
2/2
✓ Branch 0 taken 1841 times.
✓ Branch 1 taken 4270 times.
6111 else if(dx > 0)
10680 {
10681
2/2
✓ Branch 0 taken 1803 times.
✓ Branch 1 taken 38 times.
3666 if(!(solpush_walkflag(x+15+dx,y+(bigHitbox?0:8),1,this)
10682
2/2
✓ Branch 0 taken 1825 times.
✓ Branch 1 taken 16 times.
1841 || solpush_walkflag(x+15+dx,y+8,1,this)
10683
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1526 times.
✓ Branch 3 taken 299 times.
1825 || (y.getInt()&7?solpush_walkflag(x+15+dx,y+16,1,this):0)))
10684 {
10685 1803 x += dx;
10686 1803 return true;
10687 }
10688 38 return false;
10689 }
10690
2/2
✓ Branch 0 taken 2032 times.
✓ Branch 1 taken 2238 times.
4270 else if(dy < 0)
10691 {
10692
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 1 times.
4063 if(!(solpush_walkflag(x,y+(bigHitbox?0:8)+dy,2,this)
10693
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2031 times.
✓ Branch 2 taken 1723 times.
✓ Branch 3 taken 308 times.
2032 || (x.getInt()&7?solpush_walkflag(x+16,y+(bigHitbox?0:8)+dy,1,this):0)))
10694 {
10695 2031 y += dy;
10696 2031 return true;
10697 }
10698 1 return false;
10699 }
10700
1/2
✓ Branch 0 taken 2238 times.
✗ Branch 1 not taken.
2238 else if(dy > 0)
10701 {
10702
2/2
✓ Branch 0 taken 2206 times.
✓ Branch 1 taken 32 times.
4444 if(!(solpush_walkflag(x,y+15+dy,2,this)
10703
4/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 2206 times.
✓ Branch 2 taken 268 times.
✓ Branch 3 taken 1938 times.
2238 || (x.getInt()&7?solpush_walkflag(x+16,y+15+dy,1,this):0)))
10704 {
10705 2206 y += dy;
10706 2206 return true;
10707 }
10708 32 return false;
10709 }
10710 return false;
10711 7679 }
10712 3564 int32_t HeroClass::push_move(zfix dx, zfix dy)
10713 {
10714 3564 int32_t ret = 0;
10715
4/4
✓ Branch 0 taken 3409 times.
✓ Branch 1 taken 5047 times.
✓ Branch 2 taken 3564 times.
✓ Branch 3 taken 4892 times.
8456 while(dx || dy)
10716 {
10717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4892 times.
4892 if(check_pitslide() != -1)
10718 break;
10719
2/2
✓ Branch 0 taken 622 times.
✓ Branch 1 taken 4270 times.
4892 if(dy)
10720 {
10721
2/2
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 3205 times.
4270 zfix cy = (abs(dy) >= 1) ? sign(dy) : dy;
10722 4270 dy -= cy;
10723
2/2
✓ Branch 0 taken 4237 times.
✓ Branch 1 taken 33 times.
4270 if(!push_pixel(0,cy))
10724 {
10725 33 dy = 0;
10726 33 ret |= 2;
10727 33 }
10728 4270 }
10729
2/2
✓ Branch 0 taken 1483 times.
✓ Branch 1 taken 3409 times.
4892 if(dx)
10730 {
10731
2/2
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 2627 times.
3409 zfix cx = (abs(dx) >= 1) ? sign(dx) : dx;
10732 3409 dx -= cx;
10733
2/2
✓ Branch 0 taken 3371 times.
✓ Branch 1 taken 38 times.
3409 if(!push_pixel(cx,0))
10734 {
10735 38 dx = 0;
10736 38 ret |= 1;
10737 38 }
10738 3409 }
10739 }
10740 3564 return ret;
10741 }
10742
10743 14169897 bool HeroClass::setSolid(bool set)
10744 {
10745
1/2
✓ Branch 0 taken 14169897 times.
✗ Branch 1 not taken.
14169897 bool actual = set && !toogam; //not solid when noclipping
10746 14169897 bool ret = solid_object::setSolid(actual);
10747 14169897 solid = set;
10748 14169897 return ret;
10749 }
10750
10751 18082 void HeroClass::solid_push(solid_object* obj)
10752 {
10753
1/2
✓ Branch 0 taken 18082 times.
✗ Branch 1 not taken.
18082 if(obj == this) return; //can't push self
10754
10755 18082 zfix dx, dy;
10756 18082 int32_t hdir = -1;
10757 18082 solid_push_int(obj,dx,dy,hdir,!on_ffc_platform());
10758
10759
4/4
✓ Branch 0 taken 17992 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 17756 times.
✓ Branch 3 taken 236 times.
18082 if(!dx && !dy) return;
10760
10761 326 obj->doContactDamage(hdir);
10762
10763 326 bool t = obj->getTempNonsolid();
10764 326 obj->setTempNonsolid(true);
10765
10766 326 push_move(dx,dy);
10767
10768 326 obj->setTempNonsolid(t);
10769 18082 }
10770
10771 #define COND_AWPN (get_qr(qr_SELECTAWPN) ? game->awpn : 255)
10772 #define COND_BWPN (game->bwpn)
10773 #define COND_XWPN (get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : 255)
10774 #define COND_YWPN (get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : 255)
10775 //Helper function
10776 1327 static void deselectbombsWPN(word& wpos, int32_t& BTNwpn, int32_t& directItemBTN,
10777 word f1 = 255, word f2 = 255, word f3 = 255)
10778 {
10779 1327 byte pgn = wpos&0xFF, pos = wpos>>8;
10780 1327 bool empty = pgn==255;
10781
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1327 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1327 if(empty && get_qr(qr_NO_BUTTON_VERIFY)) return; //intentional nothingness
10782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1327 times.
1327 SubscrPage* pg = new_subscreen_active->get_page(pgn==255?new_subscreen_active->curpage:pgn);
10783
1/2
✓ Branch 0 taken 1327 times.
✗ Branch 1 not taken.
1327 if(!pg)
10784 {
10785 wpos = 255; //set to nothingness
10786 return;
10787 }
10788
10789
4/6
✓ Branch 0 taken 1306 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
1327 auto fp1 = ((f1&0xFF)==255) ? 255 : ((empty || (f1&0xFF)==(wpos&0xFF)) ? f1 : 255);
10790
1/6
✓ Branch 0 taken 1327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1327 auto fp2 = ((f2&0xFF)==255) ? 255 : ((empty || (f2&0xFF)==(wpos&0xFF)) ? f2 : 255);
10791
1/6
✓ Branch 0 taken 1327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1327 auto fp3 = ((f3&0xFF)==255) ? 255 : ((empty || (f3&0xFF)==(wpos&0xFF)) ? f3 : 255);
10792 1327 auto temp = pg->movepos_legacy(SEL_VERIFY_LEFT, wpos, fp1, fp2, fp3);
10793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1327 times.
1327 if((temp&0xFF) == 0xFF)
10794 BTNwpn = -1;
10795 1327 else BTNwpn = pg->get_item_pos(temp>>8);
10796
2/2
✓ Branch 0 taken 1325 times.
✓ Branch 1 taken 2 times.
1327 directItemBTN = NEG_OR_MASK(BTNwpn,0xFFF);
10797 1327 wpos = temp;
10798 1327 }
10799 // A routine used exclusively by startwpn,
10800 // to switch Hero's weapon if his current weapon (bombs) was depleted.
10801 1373 void HeroClass::deselectbombs(int32_t super)
10802 {
10803
6/10
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 1344 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1344 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1344 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1344 times.
1373 if ( get_qr(qr_NEVERDISABLEAMMOONSUBSCREEN) || itemsbuf[game->forced_awpn].family == itype_bomb || itemsbuf[game->forced_bwpn].family == itype_bomb || itemsbuf[game->forced_xwpn].family == itype_bomb || itemsbuf[game->forced_ywpn].family == itype_bomb) return;
10804
4/6
✓ Branch 0 taken 1327 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 1327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1327 times.
✗ Branch 5 not taken.
1344 if(getItemFamily(itemsbuf,Bwpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Bwpn==directWpn))
10805 {
10806
1/2
✓ Branch 0 taken 1327 times.
✗ Branch 1 not taken.
1327 if(!new_subscreen_active)
10807 return;
10808
4/6
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1306 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1327 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1327 times.
1327 deselectbombsWPN(game->bwpn, Bwpn, directItemB, COND_AWPN, COND_XWPN, COND_YWPN);
10809 1327 }
10810
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 else if (getItemFamily(itemsbuf,Xwpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Xwpn==directWpn))
10811 {
10812 if(!new_subscreen_active)
10813 return;
10814 deselectbombsWPN(game->xwpn, Xwpn, directItemX, COND_AWPN, COND_BWPN, COND_YWPN);
10815 }
10816
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 else if (getItemFamily(itemsbuf,Ywpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Ywpn==directWpn))
10817 {
10818 if(!new_subscreen_active)
10819 return;
10820 deselectbombsWPN(game->ywpn, Ywpn, directItemY, COND_AWPN, COND_XWPN, COND_BWPN);
10821 }
10822
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 else if (getItemFamily(itemsbuf,Awpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Awpn==directWpn))
10823 {
10824 if(!new_subscreen_active)
10825 return;
10826 deselectbombsWPN(game->awpn, Awpn, directItemA, COND_BWPN, COND_XWPN, COND_YWPN);
10827 }
10828 1373 }
10829
10830 int32_t potion_life=0;
10831 int32_t potion_magic=0;
10832
10833 13564085 bool HeroClass::onWater(bool drownonly)
10834 {
10835 13564085 int32_t water = 0;
10836 13564085 int32_t types[4] = {0};
10837 13564085 int32_t x1 = x+4, x2 = x+11,
10838 13564085 y1 = y+9, y2 = y+15;
10839
2/2
✓ Branch 0 taken 1061185 times.
✓ Branch 1 taken 12502900 times.
13564085 if (get_qr(qr_SMARTER_WATER))
10840 {
10841
4/4
✓ Branch 0 taken 10733 times.
✓ Branch 1 taken 1050452 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 8349 times.
1069556 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
10842
2/2
✓ Branch 0 taken 9619 times.
✓ Branch 1 taken 1114 times.
10733 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
10843
2/2
✓ Branch 0 taken 8371 times.
✓ Branch 1 taken 1248 times.
9619 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
10844 8371 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
10845 1061185 }
10846 else
10847 {
10848 12502900 types[0] = COMBOTYPE(x1,y1);
10849
10850
2/2
✓ Branch 0 taken 12382318 times.
✓ Branch 1 taken 120582 times.
12502900 if(MAPFFCOMBO(x1,y1))
10851 120582 types[0] = FFCOMBOTYPE(x1,y1);
10852
10853 12502900 types[1] = COMBOTYPE(x1,y2);
10854
10855
2/2
✓ Branch 0 taken 12396880 times.
✓ Branch 1 taken 106020 times.
12502900 if(MAPFFCOMBO(x1,y2))
10856 106020 types[1] = FFCOMBOTYPE(x1,y2);
10857
10858 12502900 types[2] = COMBOTYPE(x2,y1);
10859
10860
2/2
✓ Branch 0 taken 12381277 times.
✓ Branch 1 taken 121623 times.
12502900 if(MAPFFCOMBO(x2,y1))
10861 121623 types[2] = FFCOMBOTYPE(x2,y1);
10862
10863 12502900 types[3] = COMBOTYPE(x2,y2);
10864
10865
2/2
✓ Branch 0 taken 12393950 times.
✓ Branch 1 taken 108950 times.
12502900 if(MAPFFCOMBO(x2,y2))
10866 108950 types[3] = FFCOMBOTYPE(x2,y2);
10867
10868 12502900 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
10869
2/2
✓ Branch 0 taken 12387762 times.
✓ Branch 1 taken 115138 times.
12502900 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
10870 115138 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
10871
10872
5/6
✓ Branch 0 taken 223042 times.
✓ Branch 1 taken 12279858 times.
✓ Branch 2 taken 214266 times.
✓ Branch 3 taken 8776 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 205928 times.
12708828 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
10873
4/4
✓ Branch 0 taken 206169 times.
✓ Branch 1 taken 8097 times.
✓ Branch 2 taken 205928 times.
✓ Branch 3 taken 241 times.
214266 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
10874 205928 water = typec;
10875 }
10876
2/2
✓ Branch 0 taken 13349808 times.
✓ Branch 1 taken 214277 times.
13564085 if(water > 0)
10877 {
10878
1/2
✓ Branch 0 taken 214277 times.
✗ Branch 1 not taken.
214277 if(!drownonly) return true;
10879
7/8
✓ Branch 0 taken 139216 times.
✓ Branch 1 taken 75061 times.
✓ Branch 2 taken 139213 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 2249 times.
✓ Branch 5 taken 136964 times.
✓ Branch 6 taken 2249 times.
✗ Branch 7 not taken.
214277 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & item_flag3)))
10880 {
10881 75064 return true;
10882 }
10883 139213 }
10884 13489021 return false;
10885 13564085 }
10886
10887 bool HeroClass::mirrorBonk()
10888 {
10889 zfix tx = x, ty = y, tz = z;
10890 WalkflagInfo info = walkflag(x,y+(bigHitbox?0:8),2,up);
10891 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8));
10892 execute(info);
10893 bool fail = info.isUnwalkable();
10894
10895 if(!fail) //not solid, but check for water/pits...
10896 {
10897 if(onWater(true))
10898 fail = true;
10899 if(pitslide() || fallclk)
10900 fail = true;
10901 fallclk = 0;
10902 }
10903 x = tx; y = ty; z = tz;
10904 return fail;
10905 }
10906
10907 void HeroClass::doMirror(int32_t mirrorid)
10908 {
10909 if(z > 0 || fakez > 0) return; //No mirror in air
10910 if(mirrorid < 0)
10911 mirrorid = current_item_id(itype_mirror);
10912 if(mirrorid < 0) return;
10913
10914 if((tmpscr->flags9&fDISABLE_MIRROR) || !(checkbunny(mirrorid) && checkmagiccost(mirrorid)))
10915 {
10916 item_error();
10917 return;
10918 }
10919 static const int32_t sens = 4; //sensitivity of 'No Mirror' combos (0 most, 8 least)
10920 int32_t posarr[] = {COMBOPOS(x+sens,y+sens), COMBOPOS(x+sens,y+15-sens),
10921 COMBOPOS(x+15-sens,y+sens), COMBOPOS(x+15-sens,y+15-sens)};
10922 for(auto pos : posarr)
10923 {
10924 if(HASFLAG_ANY(mfNOMIRROR, pos)) //"No Mirror" flag touching the player
10925 {
10926 item_error();
10927 return;
10928 }
10929 }
10930
10931 itemdata const& mirror = itemsbuf[mirrorid];
10932 if(DMaps[currdmap].flags & dmfMIRRORCONTINUE)
10933 {
10934 paymagiccost(mirrorid);
10935 if(mirror.usesound2) sfx(mirror.usesound2);
10936
10937 doWarpEffect(mirror.misc2, true);
10938 if(mirror.flags & item_flag2) //Act as F6->Continue
10939 {
10940 Quit = qCONT;
10941 skipcont = 1;
10942 }
10943 else //Act as Divine Escape
10944 {
10945 int32_t div_prot_temp=div_prot_item;
10946 restart_level();
10947 div_prot_item=div_prot_temp;
10948 magicitem=-1;
10949 magiccastclk=0;
10950 if ( Hero.getDontDraw() < 2 ) { Hero.setDontDraw(0); }
10951 }
10952 }
10953 else
10954 {
10955 int32_t destdmap = DMaps[currdmap].mirrorDMap;
10956 int32_t offscr = currscr - DMaps[currdmap].xoff;
10957 if(destdmap < 0)
10958 return;
10959 int32_t destscr = DMaps[destdmap].xoff + offscr;
10960 if((offscr%16 != destscr%16) || unsigned(destscr) >= 0x80)
10961 return;
10962 paymagiccost(mirrorid);
10963
10964 //Store some values to restore if 'warp fails'
10965 int32_t tLastEntrance = lastentrance,
10966 tLastEntranceDMap = lastentrance_dmap,
10967 tContScr = game->get_continue_scrn(),
10968 tContDMap = game->get_continue_dmap(),
10969 tPortalDMap = game->saved_mirror_portal.srcdmap;
10970 int32_t sourcescr = currscr, sourcedmap = currdmap;
10971 zfix tx = x, ty = y, tz = z;
10972 game->saved_mirror_portal.srcdmap = -1;
10973 action = none; FFCore.setHeroAction(none);
10974
10975 //Warp to new dmap
10976 FFCore.warp_player(wtIWARP, destdmap, destscr, -1, -1, mirror.misc1,
10977 mirror.usesound, 0, -1);
10978
10979 //Check for valid landing location
10980 if(mirrorBonk()) //Invalid landing, warp back!
10981 {
10982 action = none; FFCore.setHeroAction(none);
10983 lastentrance = tLastEntrance;
10984 lastentrance_dmap = tLastEntranceDMap;
10985 game->set_continue_scrn(tContScr);
10986 game->set_continue_dmap(tContDMap);
10987 x = tx;
10988 y = ty;
10989 z = tz;
10990 game->saved_mirror_portal.srcdmap = tPortalDMap;
10991 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, mirror.misc1,
10992 mirror.usesound, 0, -1);
10993 }
10994 else if(mirror.flags & item_flag1) //Place portal!
10995 {
10996 //Place the portal
10997 game->set_portal(sourcedmap, destdmap, offscr, x.getZLong(), y.getZLong(), mirror.usesound, mirror.misc1, mirror.wpn);
10998 //Since it was placed after loading this screen, load the portal object now
10999 game->load_portal();
11000 //Don't immediately trigger the warp back
11001 mirror_portal.prox_active = false;
11002
11003 //Set continue point
11004 if(currdmap != game->get_continue_dmap())
11005 {
11006 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
11007 }
11008 game->set_continue_dmap(currdmap);
11009 lastentrance_dmap = currdmap;
11010 lastentrance = game->get_continue_scrn();
11011 }
11012 }
11013 }
11014
11015 14168568 void HeroClass::handle_passive_buttons()
11016 {
11017 14168568 do_liftglove(-1,true);
11018 14168568 do_jump(-1,true);
11019 14168568 }
11020
11021 static bool did_passive_jump = false;
11022 14168985 bool HeroClass::do_jump(int32_t jumpid, bool passive)
11023 {
11024
2/2
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 14168568 times.
14168985 if(passive) did_passive_jump = false;
11025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417 times.
417 else if(did_passive_jump) return false; //don't jump twice in the same frame
11026
11027
2/2
✓ Branch 0 taken 604900 times.
✓ Branch 1 taken 13564085 times.
14168985 if(nomove_action(action)) return false; //can't jump while ex. drowning
11028
2/2
✓ Branch 0 taken 75064 times.
✓ Branch 1 taken 13489021 times.
13564085 if(onWater(true)) return false; //Don't allow jumping off of water frame-perfectly...
11029
11030
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 13488606 times.
13489021 if(jumpid < 0)
11031 13488606 jumpid = current_item_id(itype_rocs,true,true);
11032
11033
2/2
✓ Branch 0 taken 13146842 times.
✓ Branch 1 taken 342179 times.
13489021 if(unsigned(jumpid) >= MAXITEMS) return false;
11034
4/4
✓ Branch 0 taken 340952 times.
✓ Branch 1 taken 1227 times.
✓ Branch 2 taken 1935 times.
✓ Branch 3 taken 339017 times.
342179 if(inlikelike || charging) return false;
11035
1/2
✓ Branch 0 taken 339017 times.
✗ Branch 1 not taken.
339017 if(!checkitem_jinx(jumpid)) return false;
11036
11037 339017 itemdata const& itm = itemsbuf[jumpid];
11038
11039 339017 bool standing = isStanding(true);
11040
3/4
✓ Branch 0 taken 323404 times.
✓ Branch 1 taken 15613 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15613 times.
339017 bool coyotejump = !standing && coyotetime < (zc_min(65535,itm.misc5));
11041
4/6
✓ Branch 0 taken 339017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15613 times.
✓ Branch 3 taken 323404 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15613 times.
339017 if(!(coyotejump || standing || extra_jump_count < itm.misc1)) return false;
11042
2/4
✓ Branch 0 taken 323404 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 323404 times.
323404 if(!(checkbunny(jumpid) && checkmagiccost(jumpid)))
11043 {
11044 item_error();
11045 return false;
11046 }
11047
11048 323404 byte intbtn = byte(itm.misc2&0xFF);
11049
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 323010 times.
323404 if(passive)
11050 {
11051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 323010 times.
323010 if(!getIntBtnInput(intbtn, true, true, false, false, true))
11052 323010 return false; //not pressed
11053 }
11054
11055 394 paymagiccost(jumpid);
11056
11057
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!standing)
11058 {
11059 ++extra_jump_count;
11060 fall = 0;
11061 fakefall = 0;
11062 if(hoverclk > 0)
11063 hoverclk = -hoverclk;
11064 }
11065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
394 if(itm.flags & item_flag1)
11066 setFall(fall - itm.power);
11067 394 else setFall(fall - (FEATHERJUMP*(itm.power+2)));
11068 394 coyotetime = 65535; //jumped, so no coyotetime
11069 394 setOnSideviewLadder(false);
11070
11071 // Reset the ladder, unless on an unwalkable combo
11072
6/10
✓ Branch 0 taken 393 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 393 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 394 times.
✗ Branch 9 not taken.
394 if((ladderx || laddery) && !(_walkflag(ladderx,laddery,0,SWITCHBLOCK_STATE)))
11073 reset_ladder();
11074
11075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
394 if(itm.usesound)
11076 394 sfx(itm.usesound,pan(x.getInt()));
11077
11078
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(passive)
11079 {
11080 did_passive_jump = true;
11081 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
11082 }
11083 394 return true;
11084 14168985 }
11085 11803 void HeroClass::drop_liftwpn()
11086 {
11087
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11802 times.
11803 if(!lift_wpn) return;
11088
11089 1 handle_lift(false); //sets position properly, accounting for large weapons
11090 1 auto liftid = current_item_id(itype_liftglove,true,true);
11091 1 itemdata const& glove = itemsbuf[liftid];
11092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(isSideViewGravity())
11093 {
11094 lift_wpn->moveflags |= move_no_fake_z;
11095 }
11096 else
11097 {
11098 1 auto lheight = liftheight+z+fakez;
11099
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(glove.flags & item_flag1)
11100 {
11101 lift_wpn->z = 0;
11102 lift_wpn->fakez = lheight;
11103 lift_wpn->moveflags |= move_no_real_z;
11104 }
11105 else
11106 {
11107 1 lift_wpn->z = lheight;
11108 1 lift_wpn->moveflags |= move_no_fake_z;
11109 }
11110 }
11111 1 lift_wpn->dir = dir;
11112 1 lift_wpn->step = 0;
11113 1 lift_wpn->fakefall = 0;
11114 1 lift_wpn->fall = 0;
11115 1 Lwpns.add(lift_wpn);
11116 1 lift_wpn = nullptr;
11117 11803 }
11118 14168568 void HeroClass::do_liftglove(int32_t liftid, bool passive)
11119 {
11120
2/2
✓ Branch 0 taken 11065 times.
✓ Branch 1 taken 14157503 times.
14168568 if(!lift_wpn)
11121 14157503 last_lift_id.reset();
11122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14168568 times.
14168568 if(liftid < 0)
11123 {
11124
4/4
✓ Branch 0 taken 10228 times.
✓ Branch 1 taken 14158340 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 9449 times.
14168568 if(last_lift_id && can_lift(*last_lift_id))
11125 9449 liftid = *last_lift_id;
11126 14159119 else liftid = current_item_id(itype_liftglove,true,true);
11127 14168568 }
11128
2/2
✓ Branch 0 taken 364561 times.
✓ Branch 1 taken 13804007 times.
14168568 if(!can_lift(liftid)) return;
11129 364561 itemdata const& glove = itemsbuf[liftid];
11130 364561 byte intbtn = byte(glove.misc1&0xFF);
11131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 364561 times.
364561 if(passive)
11132 {
11133
2/2
✓ Branch 0 taken 2270 times.
✓ Branch 1 taken 362291 times.
364561 if(!getIntBtnInput(intbtn, true, true, false, false, true))
11134 362291 return; //not pressed
11135 2270 }
11136
11137 2270 bool had_weapon = lift_wpn;
11138
11139
3/4
✓ Branch 0 taken 2203 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 2203 times.
✗ Branch 3 not taken.
4473 if(!(had_weapon || //Allow throwing while bunnied/don't charge magic for throwing
11140
1/2
✓ Branch 0 taken 2203 times.
✗ Branch 1 not taken.
2203 (checkbunny(liftid) && checkmagiccost(liftid))))
11141 {
11142 item_error();
11143 return;
11144 }
11145
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2270 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2270 if(glove.script!=0 && (FFCore.doscript(ScriptType::Item, liftid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
11146 return;
11147
11148 2270 bool paidmagic = had_weapon; //don't pay to throw, only to lift
11149
1/2
✓ Branch 0 taken 2270 times.
✗ Branch 1 not taken.
2270 if(glove.script)
11150 {
11151 if(!paidmagic)
11152 {
11153 paidmagic = true;
11154 paymagiccost(liftid);
11155 }
11156
11157 int i = liftid;
11158 FFCore.reset_script_engine_data(ScriptType::Item, i);
11159 ZScriptVersion::RunScript(ScriptType::Item, glove.script, i);
11160 FFCore.deallocateAllScriptOwned(ScriptType::Item,i);
11161
11162 bool has_weapon = lift_wpn;
11163 if(has_weapon != had_weapon) //Item action script changed the lift information
11164 {
11165 if(passive)
11166 {
11167 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
11168 }
11169 return;
11170 }
11171 }
11172
11173
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 2203 times.
2270 if(lift_wpn)
11174 {
11175
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!paidmagic)
11176 {
11177 paidmagic = true;
11178 paymagiccost(liftid);
11179 }
11180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(!liftclk)
11181 {
11182 //Throw the weapon!
11183 //hero's direction and position
11184 67 handle_lift(false); //sets position properly, accounting for large weapons
11185
11186 67 lift_wpn->dir = dir;
11187 //Configured throw speed in both axes
11188 67 auto basestep = glove.misc2;
11189 67 lift_wpn->step = zfix(basestep)/100;
11190
11191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(isSideViewGravity())
11192 {
11193 lift_wpn->fall = -glove.misc3;
11194 switch(dir)
11195 {
11196 case left: case right:
11197 break; //nothing special for sideways
11198 case up: //step converts to upwards fall
11199 lift_wpn->fall -= basestep;
11200 lift_wpn->step = 0;
11201 break;
11202 case down: //step converts into straight down fall
11203 lift_wpn->fall = zc_min(basestep,zinit.terminalv);
11204 lift_wpn->step = 0;
11205 break;
11206 }
11207 lift_wpn->moveflags |= move_no_fake_z;
11208 }
11209 else
11210 {
11211 67 auto lheight = liftheight+z+fakez;
11212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(glove.flags & item_flag1)
11213 {
11214 lift_wpn->z = 0;
11215 lift_wpn->fakez = lheight;
11216 lift_wpn->fakefall = -glove.misc3;
11217 lift_wpn->moveflags |= move_no_real_z;
11218 }
11219 else
11220 {
11221 67 lift_wpn->z = lheight;
11222 67 lift_wpn->fall = -glove.misc3;
11223 67 lift_wpn->moveflags |= move_no_fake_z;
11224 }
11225 }
11226 67 Lwpns.add(lift_wpn);
11227 67 lift_wpn = nullptr;
11228 67 last_lift_id.reset();
11229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(glove.usesound2)
11230 67 sfx(glove.usesound2,pan(int32_t(x)));
11231 67 }
11232 else last_lift_id = liftid;
11233
11234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(passive)
11235 {
11236 67 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
11237 67 }
11238 67 return;
11239 }
11240
11241 2203 bool lifted = false;
11242 //Check for a liftable weapon
11243 //if(!lifted)
11244 {
11245 2203 zfix hx, hy, hw, hh;
11246
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
✓ Branch 2 taken 581 times.
✓ Branch 3 taken 672 times.
✓ Branch 4 taken 599 times.
2203 switch(dir)
11247 {
11248 case up:
11249 351 hx = x;
11250 351 hy = y-8;
11251 351 hw = 16;
11252 351 hh = bigHitbox ? 8 : 16;
11253 351 break;
11254 case down:
11255 581 hx = x;
11256 581 hy = y+16;
11257 581 hw = 16;
11258 581 hh = 8;
11259 581 break;
11260 case left:
11261 672 hx = x-8;
11262 672 hy = y;
11263 672 hw = 8;
11264 672 hh = 16;
11265 672 break;
11266 case right:
11267 599 hx = x+16;
11268 599 hy = y;
11269 599 hw = 8;
11270 599 hh = 16;
11271 599 break;
11272 }
11273
2/2
✓ Branch 0 taken 2201 times.
✓ Branch 1 taken 113 times.
2314 for(int32_t q = 0; q < Lwpns.Count(); ++q)
11274 {
11275 113 weapon* w = (weapon*)Lwpns.spr(q);
11276
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 103 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
113 if((w->lift_level && w->lift_level <= glove.fam_type))
11277 {
11278
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if(!w->hit(hx,hy,0,hw,hh,1))
11279 8 continue;
11280 2 lift(w, w->lift_time, w->lift_height);
11281 2 Lwpns.remove(w);
11282 2 lifted = true;
11283 2 break;
11284 }
11285 103 }
11286 }
11287
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2201 times.
2203 if(!lifted) //Check for a liftable combo
11288 {
11289 2201 zfix bx, by;
11290 2201 zfix bx2, by2;
11291
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
✓ Branch 2 taken 581 times.
✓ Branch 3 taken 672 times.
✓ Branch 4 taken 597 times.
2201 switch(dir)
11292 {
11293 case up:
11294 351 by = y + (bigHitbox ? -2 : 6);
11295 351 by2 = by;
11296 351 bx = x + 4;
11297 351 bx2 = bx + 8;
11298 351 break;
11299 case down:
11300 581 by = y + 17;
11301 581 by2 = by;
11302 581 bx = x + 4;
11303 581 bx2 = bx + 8;
11304 581 break;
11305 case left:
11306 672 by = y + (bigHitbox ? 0 : 8);
11307 672 by2 = y + 8;
11308 672 bx = x - 2;
11309 672 bx2 = x - 2;
11310 672 break;
11311 case right:
11312 597 by = y + (bigHitbox ? 0 : 8);
11313 597 by2 = y + 8;
11314 597 bx = x + 17;
11315 597 bx2 = x + 17;
11316 597 break;
11317 }
11318 2201 int32_t pos = COMBOPOS_B(bx,by);
11319 2201 int32_t pos2 = COMBOPOS_B(bx2,by2);
11320 2201 int32_t foundpos = -1;
11321
11322
2/2
✓ Branch 0 taken 2152 times.
✓ Branch 1 taken 15383 times.
17535 for(auto lyr = 6; lyr >= 0; --lyr)
11323 {
11324 15383 mapscr* scr = FFCore.tempScreens[lyr];
11325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15383 times.
15383 if(pos > -1)
11326 {
11327 15383 newcombo const& cmb = combobuf[scr->data[pos]];
11328
2/2
✓ Branch 0 taken 15337 times.
✓ Branch 1 taken 46 times.
15383 if(cmb.liftflags & LF_LIFTABLE)
11329 {
11330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if(do_lift_combo(lyr,pos,liftid))
11331 {
11332 46 lifted = true;
11333 46 break;
11334 }
11335 }
11336 15337 }
11337
3/4
✓ Branch 0 taken 2209 times.
✓ Branch 1 taken 13128 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2209 times.
15337 if(pos != pos2 && pos2 > -1)
11338 {
11339 2209 newcombo const& cmb2 = combobuf[scr->data[pos2]];
11340
2/2
✓ Branch 0 taken 2206 times.
✓ Branch 1 taken 3 times.
2209 if(cmb2.liftflags & LF_LIFTABLE)
11341 {
11342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(do_lift_combo(lyr,pos2,liftid))
11343 {
11344 3 lifted = true;
11345 3 break;
11346 }
11347 }
11348 2206 }
11349 15334 }
11350 2201 }
11351
11352
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 2152 times.
2203 if(!lifted)
11353 {
11354 2152 last_lift_id.reset();
11355 2152 return;
11356 }
11357 51 last_lift_id = liftid;
11358
11359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(!paidmagic)
11360 {
11361 51 paidmagic = true;
11362 51 paymagiccost(liftid);
11363 51 }
11364 51 set_liftflags(liftid);
11365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(passive)
11366 51 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
11367 51 return;
11368 14168568 }
11369 23089 void HeroClass::handle_lift(bool dec)
11370 {
11371
1/2
✓ Branch 0 taken 23089 times.
✗ Branch 1 not taken.
23089 if(lift_wpn)
11372 23089 lift_wpn->fakez = 0;
11373 else liftclk = 0;
11374
2/2
✓ Branch 0 taken 21144 times.
✓ Branch 1 taken 1945 times.
23089 if(liftclk <= (dec?1:0))
11375 {
11376 21144 liftclk = 0;
11377 21144 tliftclk = 0;
11378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21144 times.
21144 if(lift_wpn)
11379 {
11380
2/4
✓ Branch 0 taken 21144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21144 times.
21144 if(lift_wpn->txsz > 1 || lift_wpn->tysz > 1)
11381 {
11382 lift_wpn->x = x+8 - (lift_wpn->txsz*8);
11383 lift_wpn->y = y+8 - (lift_wpn->tysz*8);
11384 }
11385 else
11386 {
11387 21144 lift_wpn->x = x;
11388 21144 lift_wpn->y = y;
11389 }
11390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21144 times.
21144 if(isSideViewGravity())
11391 lift_wpn->y -= liftheight;
11392 21144 else lift_wpn->z = liftheight;
11393 21144 }
11394
2/2
✓ Branch 0 taken 21076 times.
✓ Branch 1 taken 68 times.
21144 if(action == lifting)
11395 {
11396 68 action = none; FFCore.setHeroAction(none);
11397 68 }
11398 21144 return;
11399 }
11400
2/2
✓ Branch 0 taken 981 times.
✓ Branch 1 taken 964 times.
1945 if(dec) --liftclk;
11401 double xdist, ydist;
11402 1945 double perc = (liftclk/double(tliftclk));
11403
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
✓ Branch 2 taken 285 times.
✓ Branch 3 taken 574 times.
✓ Branch 4 taken 738 times.
1945 switch(dir)
11404 {
11405 case up:
11406 {
11407 348 xdist = 0;
11408 348 ydist = -16;
11409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
348 if(lift_wpn->txsz > 1)
11410 {
11411 xdist = -((lift_wpn->txsz*8)-8);
11412 }
11413 348 else xdist = 0;
11414
1/2
✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
348 if(lift_wpn->tysz > 1)
11415 {
11416 ydist = -(lift_wpn->tysz*16);
11417 }
11418 348 ydist *= perc;
11419 348 break;
11420 }
11421 case down:
11422 {
11423 285 xdist = 0;
11424 285 ydist = 16;
11425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
285 if(lift_wpn->txsz > 1)
11426 {
11427 xdist = -((lift_wpn->txsz*8)-8);
11428 }
11429 285 else xdist = 0;
11430 285 ydist *= perc;
11431 285 break;
11432 }
11433 case left:
11434 {
11435 574 xdist = -16;
11436 574 ydist = 0;
11437
1/2
✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
574 if(lift_wpn->txsz > 1)
11438 {
11439 xdist = -(lift_wpn->txsz*16);
11440 }
11441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 574 times.
574 if(lift_wpn->tysz > 1)
11442 {
11443 ydist = -((lift_wpn->tysz*8)-8);
11444 }
11445 574 else ydist = 0;
11446 574 xdist *= perc;
11447 574 break;
11448 }
11449 case right:
11450 {
11451 738 xdist = 16;
11452 738 ydist = 0;
11453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 738 times.
738 if(lift_wpn->tysz > 1)
11454 {
11455 ydist = -((lift_wpn->tysz*8)-8);
11456 }
11457 738 else ydist = 0;
11458 738 xdist *= perc;
11459 738 break;
11460 }
11461 }
11462
11463 1945 lift_wpn->x = x + xdist;
11464 1945 lift_wpn->y = y + ydist;
11465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1945 times.
1945 if(isSideViewGravity())
11466 lift_wpn->y -= liftheight*(1.0-perc);
11467 1945 else lift_wpn->z = liftheight*(1.0-perc);
11468 23089 }
11469 14178845 bool HeroClass::can_lift(int32_t gloveid)
11470 {
11471
2/2
✓ Branch 0 taken 13740637 times.
✓ Branch 1 taken 438208 times.
14178845 if(unsigned(gloveid) >= MAXITEMS) return false;
11472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 438208 times.
438208 if(lstunclock) return false;
11473
1/2
✓ Branch 0 taken 438208 times.
✗ Branch 1 not taken.
438208 if(!checkitem_jinx(gloveid)) return false;
11474 438208 itemdata const& glove = itemsbuf[gloveid];
11475
3/3
✓ Branch 0 taken 374059 times.
✓ Branch 1 taken 57396 times.
✓ Branch 2 taken 6753 times.
438208 switch(action)
11476 {
11477 case none: case walking:
11478 374059 break;
11479
11480 case swimming:
11481
1/2
✓ Branch 0 taken 6753 times.
✗ Branch 1 not taken.
6753 if(glove.flags & item_flag2)
11482 break;
11483 6753 return false;
11484
11485 default:
11486 57396 return false;
11487 }
11488 374059 return true;
11489 14178845 }
11490 68 void HeroClass::lift(weapon* w, byte timer, zfix height)
11491 {
11492 68 lift_wpn = w;
11493 68 liftclk = timer;
11494 68 tliftclk = timer;
11495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(height < 0)
11496 liftheight = 0;
11497 68 else liftheight = height;
11498 68 }
11499
11500 137 void HeroClass::doSwitchHook(byte style)
11501 {
11502 137 hs_switcher = true;
11503 137 pull_hero = true;
11504 //{ Load hook weapons, set them to obey special drawing
11505 137 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
11506 137 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
11507
11508
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1 times.
137 if(w)
11509 1 w->switch_hooked = true;
11510
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1 times.
137 if(hw)
11511 1 hw->switch_hooked = true;
11512
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 137 times.
142 for(int32_t j=0; j<chainlinks.Count(); j++)
11513 {
11514 5 chainlinks.spr(j)->switch_hooked = true;
11515 5 }
11516 //}
11517
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 132 times.
137 if(hooked_combopos > -1)
11518 {
11519
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 int32_t max_layer = get_qr(qr_HOOKSHOTALLLAYER) ? 6 : (get_qr(qr_HOOKSHOTLAYERFIX) ? 2 : 0);
11520 132 hooked_layerbits = 0;
11521
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 132 times.
1056 for(auto q = 0; q < 7; ++q)
11522 924 hooked_undercombos[q] = -1;
11523 132 uint16_t plpos = COMBOPOS(x+8,y+8);
11524
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 132 times.
1056 for(auto q = max_layer; q > -1; --q)
11525 {
11526 924 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[hooked_combopos]];
11527 924 newcombo const& comb2 = combobuf[FFCore.tempScreens[q]->data[plpos]];
11528 924 int32_t fl1 = FFCore.tempScreens[q]->sflag[hooked_combopos],
11529 924 fl2 = FFCore.tempScreens[q]->sflag[plpos];
11530 924 bool isPush = false;
11531
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 132 times.
924 if(isSwitchHookable(cmb))
11532 {
11533
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.type == cSWITCHHOOK)
11534 {
11535 132 uint16_t plpos = COMBOPOS(x+8,y+8);
11536
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
132 if((cmb.usrflags&cflag1) && FFCore.tempScreens[q]->data[plpos])
11537 continue; //don't swap with non-zero combo
11538
3/12
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 132 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 132 times.
132 if(zc_max(1,itemsbuf[(w && w->parentitem>-1) ? w->parentitem : current_item_id(itype_switchhook)].fam_type) < cmb.attribytes[0])
11539 continue; //too low a switchhook level
11540 132 hooked_layerbits |= 1<<q; //Swapping
11541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(cmb.usrflags&cflag3)
11542 {
11543 if(cmb.usrflags&cflag6)
11544 {
11545 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
11546 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
11547 }
11548 else
11549 {
11550 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
11551 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
11552 }
11553 }
11554 else
11555 {
11556 132 hooked_layerbits |= 1<<(q+8); //Swapping BACK
11557
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag7) //counts as 'pushblock'
11558 isPush = true;
11559 }
11560 132 }
11561 else if(isCuttableType(cmb.type))
11562 {
11563 if(isCuttableNextType(cmb.type))
11564 {
11565 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
11566 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
11567 }
11568 else
11569 {
11570 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
11571 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
11572 }
11573 hooked_layerbits |= 1<<q; //Swapping
11574 }
11575 else
11576 {
11577 hooked_layerbits |= 1<<q; //Swapping
11578 hooked_layerbits |= 1<<(q+8); //Swapping BACK
11579 }
11580 132 }
11581
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 132 times.
924 if(hooked_layerbits & (1<<(q+8))) //2-way swap, check for pushblocks
11582 {
11583
3/6
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 132 times.
✗ Branch 5 not taken.
132 if((cmb.type==cPUSH_WAIT || cmb.type==cPUSH_HW || cmb.type==cPUSH_HW2)
11584 132 && hasMainGuy())
11585 {
11586 hooked_layerbits &= ~(0x101<<q); //Can't swap yet
11587 continue;
11588 }
11589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(fl1 == mfPUSHED)
11590 {
11591 hooked_layerbits &= ~(0x101<<q); //Can't swap at all, locked in place
11592 continue;
11593 }
11594
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(fl1)
11595 {
11596 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
11597 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
11598 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
11599 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
11600 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
11601 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
11602 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
11603 isPush = true;
11604 132 }
11605
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(cmb.flag)
11606 {
11607 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
11608 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
11609 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
11610 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
11611 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
11612 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
11613 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
11614 isPush = true;
11615 132 }
11616
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(isPush) //Check for block holes / triggers
11617 {
11618 if(comb2.flag == mfBLOCKHOLE || fl2 == mfBLOCKHOLE
11619 || comb2.flag == mfBLOCKTRIGGER || fl2 == mfBLOCKTRIGGER)
11620 {
11621 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
11622 }
11623 else if(!get_qr(qr_BLOCKHOLE_SAME_ONLY))
11624 {
11625 auto maxLayer = get_qr(qr_PUSHBLOCK_LAYER_1_2) ? 2 : 0;
11626 for(auto lyr = 0; lyr < maxLayer; ++lyr)
11627 {
11628 if(lyr == q) continue;
11629 switch(FFCore.tempScreens[q]->sflag[plpos])
11630 {
11631 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
11632 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
11633 lyr=7;
11634 break;
11635 }
11636 switch(combobuf[FFCore.tempScreens[q]->data[plpos]].flag)
11637 {
11638 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
11639 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
11640 lyr=7;
11641 break;
11642 }
11643 }
11644 }
11645 }
11646 132 }
11647 924 }
11648 132 }
11649 137 switch_hooked = true;
11650 137 switchhookstyle = style;
11651
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 136 times.
✗ Branch 3 not taken.
137 switch(style)
11652 {
11653 default: case swPOOF:
11654 {
11655 1 wpndata const& spr = wpnsbuf[QMisc.sprites[sprSWITCHPOOF]];
11656
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 switchhookmaxtime = switchhookclk = zc_max(spr.frames,1) * zc_max(spr.speed,1);
11657
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(x, y, dCOMBOSPRITE, 0, QMisc.sprites[sprSWITCHPOOF]));
11658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hooked_combopos > -1)
11659 decorations.add(new comboSprite((zfix)COMBOX(hooked_combopos), (zfix)COMBOY(hooked_combopos), dCOMBOSPRITE, 0, QMisc.sprites[sprSWITCHPOOF]));
11660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(switching_object)
11661
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(switching_object->x, switching_object->y, dCOMBOSPRITE, 0, QMisc.sprites[sprSWITCHPOOF]));
11662 1 break;
11663 }
11664 case swFLICKER:
11665 {
11666 136 switchhookmaxtime = switchhookclk = 64;
11667 136 break;
11668 }
11669 case swRISE:
11670 {
11671 switchhookmaxtime = switchhookclk = 64;
11672 break;
11673 }
11674 }
11675 137 }
11676
11677 46408 bool HeroClass::startwpn(int32_t itemid)
11678 {
11679
1/2
✓ Branch 0 taken 46408 times.
✗ Branch 1 not taken.
46408 if(itemid < 0) return false;
11680 46408 itemdata const& itm = itemsbuf[itemid];
11681
6/6
✓ Branch 0 taken 10754 times.
✓ Branch 1 taken 35654 times.
✓ Branch 2 taken 8654 times.
✓ Branch 3 taken 27000 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 116 times.
46525 if(((dir==up && y<24) || (dir==down && y>128) ||
11682
6/6
✓ Branch 0 taken 13111 times.
✓ Branch 1 taken 13889 times.
✓ Branch 2 taken 13883 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 117 times.
✓ Branch 5 taken 46285 times.
46408 (dir==left && x<32) || (dir==right && x>208)) && !(get_qr(qr_ITEMSONEDGES) || inlikelike))
11683 116 return false;
11684
11685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46292 times.
46292 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
11686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46292 times.
46292 if(liftonly)
11687 {
11688 dowpn = -1;
11689 switch(itm.family)
11690 {
11691 case itype_bomb:
11692 case itype_sbomb:
11693 if(itm.flags & item_flag4)
11694 do_liftglove(-1,false);
11695 break;
11696 case itype_liftglove:
11697 do_liftglove(-1,false);
11698 break;
11699 }
11700 return false;
11701 }
11702
11703 46292 int32_t wx=x;
11704 46292 int32_t wy=y-fakez;
11705 46292 int32_t wz=z;
11706 46292 bool ret = true;
11707
11708
5/5
✓ Branch 0 taken 13849 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 10735 times.
✓ Branch 3 taken 8622 times.
✓ Branch 4 taken 13080 times.
46292 switch(dir)
11709 {
11710 case up:
11711 10735 wy-=16;
11712 10735 break;
11713
11714 case down:
11715 8622 wy+=16;
11716 8622 break;
11717
11718 case left:
11719 13080 wx-=16;
11720 13080 break;
11721
11722 case right:
11723 13849 wx+=16;
11724 13849 break;
11725 }
11726
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46292 if (IsSideSwim() && (itm.flags & item_sideswim_disabled)) return false;
11727
11728
17/27
✗ Branch 0 not taken.
✓ Branch 1 taken 2484 times.
✓ Branch 2 taken 1749 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 417 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 351 times.
✓ Branch 11 taken 1338 times.
✓ Branch 12 taken 35 times.
✓ Branch 13 taken 1837 times.
✓ Branch 14 taken 19942 times.
✓ Branch 15 taken 1791 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2335 times.
✓ Branch 18 taken 20 times.
✓ Branch 19 taken 13930 times.
✓ Branch 20 taken 12 times.
✓ Branch 21 taken 8 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
46292 switch(itm.family)
11729 {
11730 case itype_liftglove:
11731 {
11732 do_liftglove(itemid,false);
11733 dowpn = -1;
11734 ret = false;
11735 break;
11736 }
11737 case itype_potion:
11738 {
11739
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
35 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11740 {
11741 return item_error();
11742 }
11743
11744 35 paymagiccost(itemid);
11745
11746
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if(itm.misc1 || itm.misc2)
11747 {
11748 35 refill_what=REFILL_ALL;
11749 35 refill_why=itemid;
11750 35 StartRefill(REFILL_ALL);
11751 35 potion_life = game->get_life();
11752 35 potion_magic = game->get_magic();
11753
11754 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
11755 //music_pause();
11756 35 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
11757
2/2
✓ Branch 0 taken 6288 times.
✓ Branch 1 taken 35 times.
6323 while(refill())
11758 {
11759 6288 do_refill_waitframe();
11760 }
11761
11762 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
11763 //music_resume();
11764 35 ret = false;
11765 35 }
11766
11767 35 break;
11768 }
11769 case itype_bottle:
11770 {
11771 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11772 {
11773 return item_error();
11774 }
11775 if(itm.script!=0 && (FFCore.doscript(ScriptType::Item, itemid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
11776 return false;
11777
11778 size_t bind = game->get_bottle_slot(itm.misc1);
11779 bool paidmagic = false;
11780 if(itm.script)
11781 {
11782 paidmagic = true;
11783 paymagiccost(itemid);
11784
11785 int i = itemid;
11786 FFCore.reset_script_engine_data(ScriptType::Item, i);
11787 ZScriptVersion::RunScript(ScriptType::Item, itm.script, i);
11788 bind = game->get_bottle_slot(itm.misc1);
11789 }
11790 bottletype const* bt = bind ? &(QMisc.bottle_types[bind-1]) : NULL;
11791 if(bt)
11792 {
11793 word toFill[3] = { 0 };
11794 for(size_t q = 0; q < 3; ++q)
11795 {
11796 char c = bt->counter[q];
11797 if(c > -1)
11798 {
11799 if(bt->flags & (1<<q))
11800 {
11801 toFill[q] = (bt->amount[q]==100)
11802 ? game->get_maxcounter(c)
11803 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
11804 }
11805 else toFill[q] = bt->amount[q];
11806 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
11807 {
11808 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
11809 }
11810 }
11811 }
11812 word max = std::max(toFill[0], std::max(toFill[1], toFill[2]));
11813 bool run = max > 0;
11814 if(get_qr(qr_NO_BOTTLE_IF_ANY_COUNTER_FULL))
11815 run = ((bt->counter[0] > -1 && !toFill[0]) || (bt->counter[1] > -1 && !toFill[1]) || (bt->counter[2] > -1 && !toFill[2]));
11816 else
11817 {
11818 if((bt->flags & BTFLAG_CURESWJINX) && swordclk)
11819 run = true;
11820 else if((bt->flags & BTFLAG_CUREITJINX) && itemclk)
11821 run = true;
11822 }
11823 if(run || (bt->flags&BTFLAG_ALLOWIFFULL))
11824 {
11825 if(bt->flags & BTFLAG_CURESWJINX)
11826 {
11827 swordclk = 0;
11828 verifyAWpn();
11829 }
11830 if(bt->flags & BTFLAG_CUREITJINX)
11831 itemclk = 0;
11832 if(!paidmagic)
11833 paymagiccost(itemid);
11834 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
11835 sfx(itm.usesound,pan(x.getInt()));
11836 for(size_t q = 0; q < 20; ++q)
11837 do_refill_waitframe();
11838 double inc = max/60.0; //1 second
11839 double xtra[3]{ 0 };
11840 for(size_t q = 0; q < 60; ++q)
11841 {
11842 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
11843 sfx(QMisc.miscsfx[sfxREFILL]);
11844 for(size_t j = 0; j < 3; ++j)
11845 {
11846 xtra[j] += inc;
11847 word f = floor(xtra[j]);
11848 xtra[j] -= f;
11849 if(toFill[j] > f)
11850 {
11851 toFill[j] -= f;
11852 game->change_counter(f,bt->counter[j]);
11853 }
11854 else if(toFill[j])
11855 {
11856 game->change_counter(toFill[j],bt->counter[j]);
11857 toFill[j] = 0;
11858 }
11859 }
11860 do_refill_waitframe();
11861 }
11862 for(size_t j = 0; j < 3; ++j)
11863 {
11864 if(toFill[j])
11865 {
11866 game->change_counter(toFill[j],bt->counter[j]);
11867 toFill[j] = 0;
11868 }
11869 }
11870 for(size_t q = 0; q < 20; ++q)
11871 do_refill_waitframe();
11872 game->set_bottle_slot(itm.misc1, bt->next_type);
11873 }
11874 }
11875
11876 dowpn = -1;
11877 ret = false;
11878 break;
11879 }
11880
11881 case itype_note:
11882 {
11883 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11884 {
11885 return item_error();
11886 }
11887 if(!msg_active)
11888 {
11889 if(play_combo_string(itm.misc1))
11890 {
11891 sfx(itm.usesound);
11892 paymagiccost(itemid);
11893 }
11894 }
11895 dowpn = -1;
11896 ret = false;
11897 break;
11898 }
11899
11900 case itype_mirror:
11901 doMirror(itemid);
11902 if(Quit)
11903 return false;
11904 ret = false;
11905 break;
11906
11907 case itype_rocs:
11908 {
11909
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 23 times.
417 if(!do_jump(itemid,false)) return false;
11910 394 ret = false;
11911 }
11912 394 break;
11913
11914 case itype_letter:
11915 {
11916
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 if(current_item(itype_letter)==i_letter &&
11917
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tmpscr[currscr<128?0:1].room==rP_SHOP &&
11918
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tmpscr[currscr<128?0:1].guy &&
11919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ((currscr<128&&!(DMaps[currdmap].flags&dmfGUYCAVES))
11920
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 ||(currscr>=128&&DMaps[currdmap].flags&dmfGUYCAVES)) &&
11921 4 checkbunny(itemid)
11922 )
11923 {
11924 4 int32_t usedid = getItemID(itemsbuf, itype_letter,i_letter+1);
11925
11926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(usedid != -1)
11927 4 getitem(usedid, true, true);
11928
11929 4 sfx(tmpscr[currscr<128?0:1].secretsfx);
11930 4 setupscreen();
11931 4 action=none; FFCore.setHeroAction(none);
11932 4 }
11933
11934 4 ret = false;
11935 }
11936 4 break;
11937
11938 case itype_whistle:
11939 {
11940 bool whistleflag;
11941
11942
4/4
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 351 times.
351 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11943 {
11944 12 return item_error();
11945 }
11946
11947 351 paymagiccost(itemid);
11948 351 sfx(itm.usesound);
11949
11950
4/4
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 135 times.
351 if(dir==up || dir==right)
11951 216 ++blowcnt;
11952 else
11953 135 --blowcnt;
11954
11955 351 uint32_t frames_to_wait = 0;
11956
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 345 times.
351 if (replay_is_active())
11957 {
11958 // How long an sfx takes to play (`sfx_allocated`) is not deterministic,
11959 // use a fixed number of frames in replay mode.
11960 // This has changed over time.
11961
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 128 times.
345 if (replay_version_check(0, 26))
11962 {
11963 217 frames_to_wait = 180;
11964 217 }
11965
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 46 times.
128 else if (replay_version_check(27, 31))
11966 {
11967 82 frames_to_wait = 0;
11968 82 }
11969 else
11970 {
11971 46 SAMPLE* sample = sfx_get_sample(itm.usesound);
11972 ASSERT(sample);
11973
2/4
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
46 if (sample && sample->freq)
11974 46 frames_to_wait = 60 * sample->len / sample->freq;
11975 }
11976 345 }
11977
11978 351 int sfx_count = 0;
11979
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 47481 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47487 times.
✓ Branch 6 taken 47142 times.
✓ Branch 7 taken 351 times.
47493 while ((!replay_is_active() && sfx_allocated(itm.usesound)) || (replay_is_active() && sfx_count < frames_to_wait))
11980 {
11981 47142 sfx_count += 1;
11982 47142 advanceframe(true);
11983
11984
1/2
✓ Branch 0 taken 47142 times.
✗ Branch 1 not taken.
47142 if(Quit)
11985 return false;
11986 }
11987
11988
9/14
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 345 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 345 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 345 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 345 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 351 times.
✓ Branch 13 taken 6 times.
351 Lwpns.add(new weapon(x,y-fakez,z,wWhistle,0,0,dir,itemid,getUID(),false,0,1,0));
11989
11990
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 102 times.
351 if((whistleflag=findentrance(x,y,mfWHISTLE,get_qr(qr_PERMANENT_WHISTLE_SECRETS))))
11991 102 didstuff |= did_whistle;
11992
11993
3/4
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 245 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 245 times.
351 if((didstuff&did_whistle && itm.flags&item_flag1) || currscr>=128)
11994 106 return false;
11995
11996
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 239 times.
245 if(itm.flags&item_flag1) didstuff |= did_whistle;
11997
11998
4/4
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 212 times.
245 if((tmpscr->flags&fWHISTLE) || (tmpscr->flags7 & fWHISTLEWATER)
11999
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 || (tmpscr->flags7&fWHISTLEPAL))
12000 {
12001 33 whistleclk=0; // signal to start drying lake or doing other stuff
12002 33 }
12003 else
12004 {
12005 212 int32_t where = itm.misc1;
12006
12007
1/2
✓ Branch 0 taken 212 times.
✗ Branch 1 not taken.
212 if(where>right) where=dir^1;
12008
12009
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 68 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 138 times.
350 if(((DMaps[currdmap].flags&dmfWHIRLWIND && TriforceCount()) || DMaps[currdmap].flags&dmfWHIRLWINDRET) &&
12010
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
144 itm.misc2 >= 0 && itm.misc2 <= 8 && !whistleflag)
12011
4/12
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 138 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 138 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 138 times.
✗ Branch 11 not taken.
276 Lwpns.add(new weapon((zfix)(where==left?240_zf:where==right?0_zf:x),
12012
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 138 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 138 times.
✗ Branch 9 not taken.
138 (zfix)(where==down?0_zf:where==up?160_zf:y),
12013
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
138 (zfix)0,
12014 wWind,
12015 0, //type
12016 0,
12017 138 where,
12018
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
138 itemid,getUID(),false,false,true,0)); //last arg is byte special, used to override type for wWind for now. -Z 18JULY2020
12019
12020 206 whistleitem=itemid;
12021 }
12022
12023 239 ret = false;
12024 }
12025 239 break;
12026
12027 case itype_bomb:
12028 {
12029 //Remote detonation
12030
3/4
✓ Branch 0 taken 1338 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1334 times.
1338 if(Lwpns.idCount(wLitBomb) >= zc_max(itm.misc2,1))
12031 {
12032 4 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
12033
12034
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 while(Lwpns.idCount(wLitBomb) && ew->misc == 0)
12035 {
12036 //If this ever needs a version check, in the future. -z
12037 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 ) )
12038 {
12039 if ( ew->power > 1 ) //Don't reduce 1 to 0. -Z
12040 ew->power *= 0.5; //Remote bombs were dealing double damage. -Z
12041 }
12042 ew->misc=50;
12043 ew->clk=ew->misc-3;
12044 ew->id=wBomb;
12045 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
12046 }
12047
12048 4 deselectbombs(false);
12049 4 return false;
12050 }
12051
12052
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1317 times.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
1334 if((itm.flags & item_flag4) && lift_wpn)
12053 {
12054 do_liftglove(-1,false); //Throw the already-held weapon
12055 return false;
12056 }
12057
2/4
✓ Branch 0 taken 1334 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1334 times.
1334 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12058 {
12059 return item_error();
12060 }
12061
12062 1334 paymagiccost(itemid);
12063
12064
1/2
✓ Branch 0 taken 1334 times.
✗ Branch 1 not taken.
1334 if(itm.misc1>0) // If not remote bombs
12065 1334 deselectbombs(false);
12066
12067
2/2
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 954 times.
1334 if(isdungeon())
12068 {
12069
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 918 times.
954 wy=zc_max(wy,16);
12070 954 }
12071
12072
4/8
✓ Branch 0 taken 1334 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1334 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1334 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1334 times.
✗ Branch 7 not taken.
2668 weapon* wpn = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitBomb,itm.fam_type,
12073
2/4
✓ Branch 0 taken 1334 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1334 times.
✗ Branch 3 not taken.
1334 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true);
12074 1334 bool lifted = false;
12075
2/2
✓ Branch 0 taken 1317 times.
✓ Branch 1 taken 17 times.
1334 if(itm.flags & item_flag4)
12076 {
12077 17 auto liftid = current_item_id(itype_liftglove);
12078 17 itemdata const& glove = itemsbuf[liftid];
12079
3/6
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17 times.
✗ Branch 5 not taken.
17 if(liftid > -1 && (!itm.misc4 || itm.misc4 <= glove.fam_type))
12080 {
12081 17 lift(wpn,itm.misc5,itm.misc6);
12082 17 set_liftflags(liftid);
12083 17 lifted = true;
12084 17 }
12085 17 }
12086
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1317 times.
1334 if(!lifted)
12087 {
12088 1317 Lwpns.add(wpn);
12089 1317 sfx(WAV_PLACE,pan(wx));
12090 1317 }
12091 }
12092 1334 break;
12093
12094 case itype_sbomb:
12095 {
12096 //Remote detonation
12097
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
35 if(Lwpns.idCount(wLitSBomb) >= zc_max(itm.misc2,1))
12098 {
12099 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
12100
12101 while(Lwpns.idCount(wLitSBomb) && ew->misc == 0)
12102 {
12103 ew->misc=50;
12104 ew->clk=ew->misc-3;
12105 ew->id=wSBomb;
12106 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
12107 }
12108
12109 deselectbombs(true);
12110 return false;
12111 }
12112
12113
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if((itm.flags & item_flag4) && lift_wpn)
12114 {
12115 do_liftglove(-1,false); //Throw the already-held weapon
12116 return false;
12117 }
12118
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
35 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12119 {
12120 return item_error();
12121 }
12122
12123 35 paymagiccost(itemid);
12124
12125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(itm.misc1>0) // If not remote bombs
12126 35 deselectbombs(true);
12127
12128
6/12
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 35 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 35 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 35 times.
✗ Branch 11 not taken.
35 weapon* wpn = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitSBomb,itm.fam_type,itm.power*game->get_hero_dmgmult(),dir, itemid,getUID(),false,false,true);
12129 35 bool lifted = false;
12130
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(itm.flags & item_flag4)
12131 {
12132 auto liftid = current_item_id(itype_liftglove);
12133 itemdata const& glove = itemsbuf[liftid];
12134 if(liftid > -1 && (!itm.misc4 || itm.misc4 <= glove.fam_type))
12135 {
12136 lift(wpn,itm.misc5,itm.misc6);
12137 set_liftflags(liftid);
12138 lifted = true;
12139 }
12140 }
12141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!lifted)
12142 {
12143 35 Lwpns.add(wpn);
12144 35 sfx(WAV_PLACE,pan(wx));
12145 35 }
12146 }
12147 35 break;
12148
12149 case itype_wand:
12150 {
12151
2/2
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 1397 times.
1837 if(Lwpns.idCount(wMagic))
12152 {
12153 440 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
12154 440 return false;
12155 }
12156
12157 1397 int32_t bookid = current_item_id(itype_book);
12158
3/4
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 681 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 716 times.
1397 bool paybook = (bookid>-1 && checkbunny(bookid) && checkmagiccost(bookid));
12159
12160
4/4
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 1224 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 139 times.
1397 if(!(itm.flags&item_flag1) && !paybook) //Can the wand shoot without the book?
12161 {
12162 139 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
12163 139 return false;
12164 }
12165
12166
4/6
✓ Branch 0 taken 1258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1258 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1255 times.
✓ Branch 5 taken 3 times.
1258 if(!checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_WAND_COST || checkmagiccost(itemid)))
12167 {
12168 3 return item_error();
12169 }
12170
12171
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1251 times.
1255 if(Lwpns.idCount(wBeam))
12172 4 Lwpns.del(Lwpns.idFirst(wBeam));
12173
12174 int32_t type, pow;
12175
2/2
✓ Branch 0 taken 533 times.
✓ Branch 1 taken 722 times.
1255 if ( get_qr(qr_BROKENBOOKCOST) )
12176 {
12177
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 413 times.
533 type = bookid != -1 ? current_item(itype_book) : itm.fam_type;
12178
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 413 times.
533 pow = (bookid != -1 ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
12179 533 }
12180 else
12181 {
12182
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 419 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
722 type = (bookid != -1 && paybook) ? current_item(itype_book) : itm.fam_type;
12183
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 419 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
722 pow = ((bookid != -1 && paybook) ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
12184 }
12185
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1255 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2510 times.
✓ Branch 4 taken 1255 times.
✓ Branch 5 taken 1255 times.
2510 for(int32_t i=(spins==1?up:dir); i<=(spins==1 ? right:dir); i++)
12186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1255 times.
2510 if(dir!=(i^1))
12187 {
12188
5/10
✓ Branch 0 taken 1255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1255 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1255 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1255 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1255 times.
✗ Branch 9 not taken.
1255 weapon *magic = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wMagic,type,pow,i, itemid,getUID(),false,false,true);
12189
2/2
✓ Branch 0 taken 539 times.
✓ Branch 1 taken 716 times.
1255 if(paybook)
12190 716 magic->linkedItem = bookid;
12191 //magic->dir = this->dir; //Save player dir for special weapons.
12192 1255 Lwpns.add(magic);
12193 1255 }
12194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1255 times.
1255 if(!(misc_internal_hero_flags & LF_PAID_WAND_COST))
12195 1255 paymagiccost(itemid);
12196 else misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
12197
12198
2/2
✓ Branch 0 taken 539 times.
✓ Branch 1 taken 716 times.
1255 if(paybook)
12199 716 paymagiccost(current_item_id(itype_book));
12200
12201
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 539 times.
1255 if(bookid != -1)
12202 {
12203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if (( itemsbuf[bookid].flags & item_flag4 ))
12204 {
12205 sfx(itemsbuf[bookid].misc2,pan(wx));
12206 }
12207 else
12208 {
12209 716 sfx(itm.usesound,pan(wx));
12210 }
12211 716 }
12212 else
12213 539 sfx(itm.usesound,pan(wx));
12214 }
12215 /*
12216 // Fireball Wand
12217 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wRefFireball,0,2*game->get_hero_dmgmult(),dir));
12218 switch (dir)
12219 {
12220 case up:
12221 Lwpns.spr(Lwpns.Count()-1)->angle=-PI/2;
12222 Lwpns.spr(Lwpns.Count()-1)->dir=up;
12223 break;
12224 case down:
12225 Lwpns.spr(Lwpns.Count()-1)->angle=PI/2;
12226 Lwpns.spr(Lwpns.Count()-1)->dir=down;
12227 break;
12228 case left:
12229 Lwpns.spr(Lwpns.Count()-1)->angle=PI;
12230 Lwpns.spr(Lwpns.Count()-1)->dir=left;
12231 break;
12232 case right:
12233 Lwpns.spr(Lwpns.Count()-1)->angle=0;
12234 Lwpns.spr(Lwpns.Count()-1)->dir=right;
12235 break;
12236 }
12237 Lwpns.spr(Lwpns.Count()-1)->clk=16;
12238 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step=3.5;
12239 Lwpns.spr(Lwpns.Count()-1)->dummy_bool[0]=true; //homing
12240 */
12241 1255 break;
12242
12243 case itype_sword:
12244 {
12245
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 19942 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
19942 if(!(checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_SWORD_COST || checkmagiccost(itemid))))
12246 {
12247 return item_error();
12248 }
12249
12250
4/4
✓ Branch 0 taken 4249 times.
✓ Branch 1 taken 15693 times.
✓ Branch 2 taken 4249 times.
✓ Branch 3 taken 15693 times.
19942 if((Lwpns.idCount(wBeam) && spins==0)||Lwpns.idCount(wMagic))
12251 {
12252 4249 misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12253 4249 return false;
12254 }
12255
12256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15693 times.
15693 if(!(misc_internal_hero_flags & LF_PAID_SWORD_COST))//If already paid to use sword melee, don't charge again
12257 15693 paymagiccost(itemid);
12258 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12259 float temppower;
12260
12261
1/2
✓ Branch 0 taken 15693 times.
✗ Branch 1 not taken.
15693 if(itm.flags & item_flag2)
12262 {
12263 15693 temppower=game->get_hero_dmgmult()*itm.power;
12264 15693 temppower=temppower*itm.misc2;
12265 15693 temppower=temppower/100;
12266 15693 }
12267 else
12268 {
12269 temppower = game->get_hero_dmgmult()*itm.misc2;
12270 }
12271
12272 //Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID()));
12273 //Add weapon script to sword beams.
12274
5/10
✓ Branch 0 taken 15693 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15693 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15693 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15693 times.
✗ Branch 9 not taken.
15693 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID(),false,false,true));
12275 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //the pointer to this beam
12276 //w->weaponscript = itm.weaponscript;
12277 //w->canrunscript = 0;
12278 15693 sfx(WAV_BEAM,pan(wx));
12279 }
12280 15693 break;
12281
12282 case itype_candle:
12283 {
12284 1791 int32_t countid = itemid;
12285
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 1716 times.
1791 if(get_qr(qr_CANDLES_SHARED_LIMIT))
12286 1716 countid = -itype_candle;
12287
5/6
✓ Branch 0 taken 1395 times.
✓ Branch 1 taken 396 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 396 times.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 1772 times.
1791 if(itm.flags&item_flag1 && usecounts[countid] >= zc_max(1, itm.misc3))
12288 {
12289 19 return false;
12290 }
12291
12292
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1772 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 1676 times.
1772 if(Lwpns.idCount(wFire) >= (itm.misc2 < 1 ? 2 : itm.misc2))
12293 {
12294 96 return false;
12295 }
12296
12297
3/4
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 1667 times.
1676 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12298 {
12299 9 return item_error();
12300 }
12301
12302 1667 paymagiccost(itemid);
12303
12304
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 1298 times.
1667 if(itm.flags&item_flag1) ++usecounts[countid];
12305
12306
4/8
✓ Branch 0 taken 1667 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1667 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1667 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1667 times.
✗ Branch 7 not taken.
3334 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wFire,
12307 //(itm.fam_type > 1), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
12308 1667 (itm.fam_type), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
12309
2/4
✓ Branch 0 taken 1667 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1667 times.
✗ Branch 3 not taken.
1667 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12310 1667 sfx(itm.usesound,pan(wx));
12311 1667 attack=wFire;
12312 }
12313 1667 break;
12314
12315 case itype_script1: case itype_script2: case itype_script3: case itype_script4: case itype_script5:
12316 case itype_script6: case itype_script7: case itype_script8: case itype_script9: case itype_script10:
12317 {
12318 int32_t wtype = wScript1 + (itm.family-itype_script1);
12319 if(Lwpns.idCount(wtype))
12320 return false;
12321
12322 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12323 {
12324 return item_error();
12325 }
12326
12327 if(!get_qr(qr_CUSTOMWEAPON_IGNORE_COST))
12328 paymagiccost(itemid);
12329
12330 zfix wpnstep = zfix(itm.misc1)/100;
12331 if(replay_version_check(0,30))
12332 wpnstep = itm.misc1/100;
12333
12334 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wtype,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
12335 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = wpnstep;
12336 sfx(itm.usesound,pan(wx));
12337 }
12338 break;
12339
12340 case itype_icerod:
12341 {
12342 if(Lwpns.idCount(wIce))
12343 return false;
12344
12345 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12346 {
12347 return item_error();
12348 }
12349
12350 if(!get_qr(qr_CUSTOMWEAPON_IGNORE_COST))
12351 paymagiccost(itemid);
12352
12353 zfix wpnstep = zfix(itm.misc1)/100;
12354 if(replay_version_check(0,30))
12355 wpnstep = itm.misc1/100;
12356
12357 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wIce,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
12358 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = wpnstep;
12359 sfx(itm.usesound,pan(wx));
12360 }
12361 break;
12362
12363 case itype_arrow:
12364 {
12365
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2335 times.
✓ Branch 2 taken 89 times.
✓ Branch 3 taken 2246 times.
2335 if(Lwpns.idCount(wArrow) >= (itm.misc2 < 1 ? 1 : itm.misc2))
12366 89 return false;
12367
12368
3/4
✓ Branch 0 taken 2246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 2232 times.
2246 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12369 {
12370 14 return item_error();
12371 }
12372
12373 2232 paymagiccost(itemid);
12374
12375
6/12
✓ Branch 0 taken 2232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2232 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2232 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2232 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2232 times.
✗ Branch 11 not taken.
2232 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wArrow,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
12376 2232 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step*=(current_item_power(itype_bow)+1)/2;
12377 2232 sfx(itm.usesound,pan(wx));
12378 }
12379 2232 break;
12380
12381 case itype_bait:
12382 {
12383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(Lwpns.idCount(wBait)) //TODO: More than one Bait per screen?
12384 return false;
12385
12386
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 3 times.
20 if(!checkbunny(itemid))
12387 3 return item_error();
12388
12389
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
33 bool grumble = (tmpscr->room==rGRUMBLE && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)));
12390
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 bool checkcost = grumble || !(itm.flags & item_flag4);
12391
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 bool paycost = grumble || !(itm.flags & (item_flag4|item_flag5));
12392
12393
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17 if(!grumble && (itm.flags & item_flag2))
12394 return item_error(); //Only usable for grumble rooms
12395
12396
2/4
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
17 if(checkcost && !checkmagiccost(itemid))
12397 return item_error();
12398
12399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(paycost)
12400 17 paymagiccost(itemid);
12401 17 sfx(itm.usesound,pan(wx));
12402
12403
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 if(grumble)
12404 {
12405
4/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
16 items.add(new item((zfix)wx,(zfix)wy,(zfix)0,itemid,ipDUMMY+ipFADE,0));
12406 16 fadeclk=66;
12407 16 dismissmsg();
12408 16 clear_bitmap(pricesdisplaybuf);
12409 16 set_clip_state(pricesdisplaybuf, 1);
12410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
12411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itm.flags & item_flag3)) //"Don't remove when feeding" flag
12412 {
12413 16 removeItemsOfFamily(game,itemsbuf,itype_bait);
12414 16 verifyBothWeapons();
12415 16 }
12416 16 sfx(tmpscr->secretsfx);
12417 16 return false;
12418 }
12419
12420
5/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
1 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBait,0,0,dir,itemid,getUID(),false,false,true));
12421 1 break;
12422 }
12423
12424 case itype_brang:
12425 {
12426
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 13603 times.
13930 if(Lwpns.idCount(wBrang) > itm.misc2)
12427 327 return false;
12428
12429
2/4
✓ Branch 0 taken 13603 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13603 times.
13603 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12430 {
12431 return item_error();
12432 }
12433
12434 13603 paymagiccost(itemid);
12435 13603 current_item_power(itype_brang);
12436
6/12
✓ Branch 0 taken 13603 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13603 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13603 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13603 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 13603 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 13603 times.
✗ Branch 11 not taken.
13603 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBrang,itm.fam_type,(itm.power*game->get_hero_dmgmult()),dir,itemid,getUID(),false,false,true));
12437 }
12438 13603 break;
12439
12440 case itype_hookshot:
12441 case itype_switchhook:
12442 {
12443
3/4
✓ Branch 0 taken 2483 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2483 times.
2484 if(inlikelike || Lwpns.idCount(wHookshot))
12444 1 return false;
12445
12446
2/4
✓ Branch 0 taken 2483 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2483 times.
2483 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12447 {
12448 return item_error();
12449 }
12450 2483 bool sw = itm.family == itype_switchhook;
12451
12452
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2481 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2483 if(sw && (itm.flags&item_flag8))
12453 switchhook_cost_item = itemid;
12454 2483 else paymagiccost(itemid);
12455
12456 2483 bool use_hookshot=true;
12457 2483 bool hit_hs = false, hit_solid = false, insta_switch = false;
12458
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 2384 times.
2483 int32_t max_layer = get_qr(qr_HOOKSHOTALLLAYER) ? 6 : (get_qr(qr_HOOKSHOTLAYERFIX) ? 2 : 0);
12459 2483 int32_t cpos = -1, ffcpos = -1;
12460
4/4
✓ Branch 0 taken 2449 times.
✓ Branch 1 taken 5758 times.
✓ Branch 2 taken 5724 times.
✓ Branch 3 taken 2483 times.
8207 for(int32_t i=0; i<=max_layer && !hit_hs; ++i)
12461 {
12462
2/2
✓ Branch 0 taken 1005 times.
✓ Branch 1 taken 4719 times.
5724 if(dir==up)
12463 {
12464
2/2
✓ Branch 0 taken 981 times.
✓ Branch 1 taken 24 times.
1005 if(check_hshot(i,x+2,y-7,sw, &cpos, &ffcpos))
12465 24 hit_hs = true;
12466 1005 }
12467
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 3673 times.
4719 else if(dir==down)
12468 {
12469
1/2
✓ Branch 0 taken 1046 times.
✗ Branch 1 not taken.
1046 if(check_hshot(i,x+12,y+23,sw, &cpos, &ffcpos))
12470 hit_hs = true;
12471 1046 }
12472
2/2
✓ Branch 0 taken 1822 times.
✓ Branch 1 taken 1851 times.
3673 else if(dir==left)
12473 {
12474
2/2
✓ Branch 0 taken 1813 times.
✓ Branch 1 taken 9 times.
1822 if(check_hshot(i,x-7,y+12,sw, &cpos, &ffcpos))
12475 9 hit_hs = true;
12476 1822 }
12477
1/2
✓ Branch 0 taken 1851 times.
✗ Branch 1 not taken.
1851 else if(dir==right)
12478 {
12479
2/2
✓ Branch 0 taken 1848 times.
✓ Branch 1 taken 3 times.
1851 if(check_hshot(i,x+23,y+12,sw, &cpos, &ffcpos))
12480 3 hit_hs = true;
12481 1851 }
12482 //Diagonal Hookshot (6)
12483 else if(dir==r_down)
12484 {
12485 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
12486 hit_hs = true;
12487 }
12488 else if(dir==l_down)
12489 {
12490 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
12491 hit_hs = true;
12492 }
12493 else if(dir==r_up)
12494 {
12495 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
12496 hit_hs = true;
12497 }
12498 else if(dir==l_up)
12499 {
12500 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
12501 hit_hs = true;
12502 }
12503 5724 }
12504
8/10
✓ Branch 0 taken 2067 times.
✓ Branch 1 taken 416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 416 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 416 times.
✓ Branch 6 taken 362 times.
✓ Branch 7 taken 54 times.
✓ Branch 8 taken 2454 times.
✓ Branch 9 taken 29 times.
2483 if(dir==up && _walkflag(x+2,y+4,1,SWITCHBLOCK_STATE) && !ishookshottable(x.getInt(),int32_t(y+4)))
12505 29 hit_solid = true;
12506
2/2
✓ Branch 0 taken 2447 times.
✓ Branch 1 taken 36 times.
2483 if(hit_hs)
12507 {
12508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(sw)
12509 insta_switch = true; //switch immediately
12510 36 else use_hookshot = false; //No hooking against grabbable
12511 36 }
12512
3/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 2454 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
2483 if(hit_solid && !insta_switch)
12513 29 use_hookshot = false;
12514
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 2433 times.
2483 if(use_hookshot)
12515 {
12516 2433 int32_t hookitem = itm.fam_type;
12517 2433 int32_t hookpower = itm.power;
12518 2433 byte allow_diagonal = (itm.flags & item_flag2) ? 1 : 0;
12519
12520
1/2
✓ Branch 0 taken 2433 times.
✗ Branch 1 not taken.
2433 if(!Lwpns.has_space())
12521 {
12522 Lwpns.del(0);
12523 }
12524
12525
1/2
✓ Branch 0 taken 2433 times.
✗ Branch 1 not taken.
2433 if(!Lwpns.has_space(2))
12526 {
12527 Lwpns.del(0);
12528 }
12529
12530
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 378 times.
✓ Branch 2 taken 440 times.
✓ Branch 3 taken 783 times.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
2433 switch(dir)
12531 {
12532 case up:
12533 {
12534 378 hookshot_used=true;
12535 378 hs_switcher = sw;
12536
4/8
✓ Branch 0 taken 378 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 378 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 378 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 378 times.
✗ Branch 7 not taken.
756 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12537
2/4
✓ Branch 0 taken 378 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 378 times.
✗ Branch 3 not taken.
378 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12538 378 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12539
5/10
✓ Branch 0 taken 378 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 378 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 378 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 378 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 378 times.
✗ Branch 9 not taken.
756 Lwpns.add(new weapon((zfix)wx,(zfix)wy-4,(zfix)wz,wHookshot,hookitem,
12540
2/4
✓ Branch 0 taken 378 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 378 times.
✗ Branch 3 not taken.
378 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12541 378 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12542 378 hs_startx=wx;
12543 378 hs_starty=wy-4;
12544 }
12545 378 break;
12546
12547 case down:
12548 {
12549 440 int32_t offset=get_qr(qr_HOOKSHOTDOWNBUG)?4:0;
12550 440 hookshot_used=true;
12551 440 hs_switcher = sw;
12552
5/10
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 440 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 440 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 440 times.
✗ Branch 9 not taken.
880 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
12553
2/4
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
440 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12554 440 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12555
5/10
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 440 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 440 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 440 times.
✗ Branch 9 not taken.
880 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
12556
2/4
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
440 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12557 440 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12558 440 hs_startx=wx;
12559 440 hs_starty=wy;
12560 }
12561 440 break;
12562
12563 case left:
12564 {
12565 783 hookshot_used=true;
12566 783 hs_switcher = sw;
12567
4/8
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 783 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 783 times.
✗ Branch 7 not taken.
1566 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12568
2/4
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
783 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12569 783 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12570
4/8
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 783 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 783 times.
✗ Branch 7 not taken.
1566 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12571
2/4
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
783 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12572 783 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12573 783 hs_startx=wx-4;
12574 783 hs_starty=wy;
12575 }
12576 783 break;
12577
12578 case right:
12579 {
12580 832 hookshot_used=true;
12581 832 hs_switcher = sw;
12582
4/8
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 832 times.
✗ Branch 7 not taken.
1664 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12583
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
832 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12584 832 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12585
4/8
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 832 times.
✗ Branch 7 not taken.
1664 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12586
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
832 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12587 832 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12588 832 hs_startx=wx+4;
12589 832 hs_starty=wy;
12590 }
12591 832 break;
12592 //Diagonal Hookshot (7)
12593 case r_down:
12594 {
12595 hookshot_used=true;
12596 hs_switcher = sw;
12597 int32_t offset=get_qr(qr_HOOKSHOTDOWNBUG)?4:0;
12598 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
12599 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12600 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12601 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
12602 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12603 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12604 hs_startx=wx+4;
12605 hs_starty=wy;
12606 }
12607 break;
12608
12609 case r_up:
12610 {
12611 hookshot_used=true;
12612 hs_switcher = sw;
12613 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12614 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12615 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12616 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12617 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12618 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12619 hs_startx=wx+4;
12620 hs_starty=wy;
12621 }
12622 break;
12623
12624 case l_down:
12625 {
12626 hookshot_used=true;
12627 hs_switcher = sw;
12628 int32_t offset=get_qr(qr_HOOKSHOTDOWNBUG)?4:0;
12629 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
12630 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12631 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12632 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
12633 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12634 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12635 hs_startx=wx+4;
12636 hs_starty=wy;
12637 }
12638 break;
12639
12640 case l_up:
12641 {
12642 hookshot_used=true;
12643 hs_switcher = sw;
12644 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12645 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12646 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12647 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12648 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12649 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12650 hs_startx=wx+4;
12651 hs_starty=wy;
12652 }
12653 break;
12654 }
12655 2433 hookshot_frozen=true;
12656 2433 }
12657
1/2
✓ Branch 0 taken 2483 times.
✗ Branch 1 not taken.
2483 if(insta_switch)
12658 {
12659 weapon* w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot));
12660 if (cpos > -1) hooked_combopos = cpos;
12661 if (ffcpos > -1)
12662 {
12663 switching_object = &(tmpscr->ffcs[ffcpos]);
12664 switching_object->switch_hooked = true;
12665 }
12666 w->misc=2;
12667 w->step=0;
12668 doSwitchHook(itm.misc5);
12669 if(itm.usesound2)
12670 sfx(itm.usesound2,pan(int32_t(x)));
12671 else if(QMisc.miscsfx[sfxSWITCHED])
12672 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
12673 stop_sfx(itm.usesound);
12674 }
12675 }
12676 2483 break;
12677
12678 case itype_divinefire:
12679
3/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
12 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(this) || getOnSideviewLadder() || IsSideSwim())))
12680 return false;
12681
12682
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12683 {
12684 return item_error();
12685 }
12686
12687 12 paymagiccost(itemid);
12688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
12689 12 else {action=casting; FFCore.setHeroAction(casting);}
12690 12 magicitem=itemid;
12691 12 break;
12692
12693 case itype_divineescape:
12694
3/12
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(this) || getOnSideviewLadder() || IsSideSwim())))
12695 return false;
12696
12697
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12698 {
12699 return item_error();
12700 }
12701
12702 8 paymagiccost(itemid);
12703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
12704 8 else {action=casting; FFCore.setHeroAction(casting);}
12705 8 magicitem=itemid;
12706 8 break;
12707
12708 case itype_divineprotection:
12709 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(this) || getOnSideviewLadder() || IsSideSwim())))
12710 return false;
12711
12712 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12713 {
12714 return item_error();
12715 }
12716
12717 paymagiccost(itemid);
12718 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
12719 else {action=casting; FFCore.setHeroAction(casting);}
12720 magicitem=itemid;
12721 break;
12722
12723 case itype_cbyrna:
12724 {
12725 //Beams already deployed
12726
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(Lwpns.idCount(wCByrna))
12727 {
12728 2 stopCaneOfByrna();
12729 2 return false;
12730 }
12731
12732
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12733 {
12734 stop_sfx(itm.usesound); //if we can't pay the cost, kill the sound.
12735 //last_cane_of_byrna_item_id = -1; //no, we'd do this in a byrna cleanup function.
12736 return false;
12737 }
12738
12739 2 paymagiccost(itemid);
12740 2 last_cane_of_byrna_item_id = itemid;
12741 //zprint("itm.misc3: %d\n", itm.misc3);
12742
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 for(int32_t i=0; i<itm.misc3; i++)
12743 {
12744 //byrna weapons are added here
12745 //space them apart
12746 //zprint("Added byrna weapon %d.\n", i);
12747 //the iterator isn passed to 'type'. weapons.cpp converts thisd to
12748 //'quantity_iterator' pn construction; and this is used for orbit initial spacing.
12749
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
2 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12750 //Lwpns.add(new weapon((zfix)wx+cos(2 * PI / (i+1)),(zfix)wy+sin(2 * PI / (i+1)),(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12751 //wx += cos(2 * PI / (itm.misc3-i));
12752 //wy += sin(2 * PI / (itm.misc3-i));
12753 2 }
12754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!(Lwpns.idCount(wCByrna)))
12755 stop_sfx(itm.usesound); //If we can't create the beams, kill the sound.
12756 }
12757 2 break;
12758
12759 case itype_clock:
12760 {
12761 ret = false;
12762 if(!(itm.flags & item_flag1))
12763 break; //Passive clock, don't use
12764 if((itm.flags & item_flag2) && watch) //"Can't activate while clock active"
12765 break;
12766 if(!(checkbunny(itemid) && checkmagiccost(itemid))) //cost/bunny check
12767 {
12768 return item_error();
12769 }
12770
12771 paymagiccost(itemid);
12772
12773 setClock(watch=true);
12774
12775 for(int32_t i=0; i<eMAXGUYS; i++)
12776 clock_zoras[i]=0;
12777
12778 clockclk=itm.misc1;
12779 sfx(itm.usesound);
12780 break;
12781 }
12782 case itype_killem:
12783 {
12784 ret = false;
12785 if(!(itm.flags & item_flag1))
12786 break; //Passive killemall, don't use
12787
12788 if(!(checkbunny(itemid) && checkmagiccost(itemid))
12789 || !can_kill_em_all()) //No enemies onscreen
12790 {
12791 return item_error();
12792 }
12793
12794 paymagiccost(itemid);
12795
12796 kill_em_all();
12797 sfx(itm.usesound);
12798 break;
12799 }
12800 case itype_refill:
12801 {
12802 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12803 {
12804 return item_error();
12805 }
12806
12807 bool did_something = false;
12808
12809 if(itm.flags & item_flag1) //Cure sword jinx
12810 {
12811 if(swordclk)
12812 did_something = true;
12813 swordclk = 0;
12814 verifyAWpn();
12815 }
12816 for(auto q = 0; q < 5; ++q)
12817 {
12818 auto ctr = itm.misc(q);
12819 if(unsigned(ctr) >= MAX_COUNTERS)
12820 continue;
12821 int16_t amnt = vbound(itm.misc(q+5),-32768,32767);
12822 if(!amnt) continue;
12823 bool gradual = itm.flags & item_flag2;
12824 if(amnt > 0)
12825 {
12826 if(game->get_counter(ctr) + game->get_dcounter(ctr) >= game->get_maxcounter(ctr))
12827 {
12828 //Can't *do* anything... skip
12829 continue;
12830 }
12831 if(game->get_counter(ctr) >= game->get_maxcounter(ctr))
12832 {
12833 //Can't do anything unless affecting dcounter
12834 gradual = true;
12835 }
12836 }
12837 else //Negative
12838 {
12839 if(game->get_counter(ctr) + game->get_dcounter(ctr) <= 0)
12840 {
12841 //Can't *do* anything... skip
12842 continue;
12843 }
12844 if(game->get_counter(ctr) <= 0)
12845 {
12846 //Can't do anything unless affecting dcounter
12847 gradual = true;
12848 }
12849 }
12850 did_something = true;
12851 if(gradual) //Gradual
12852 {
12853 game->change_dcounter(amnt, ctr);
12854 }
12855 else
12856 {
12857 game->change_counter(amnt, ctr);
12858 }
12859 }
12860 if(!did_something)
12861 {
12862 return item_error();
12863 }
12864 paymagiccost(itemid);
12865 sfx(itm.usesound);
12866 ret = false;
12867 break;
12868 }
12869
12870 default:
12871 1749 ret = false;
12872 1749 }
12873
12874
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 40711 times.
40746 if(itm.flags & item_downgrade)
12875 {
12876 35 game->set_item(itemid,false);
12877
12878 // Maybe Item Override has allowed the same item in both slots?
12879
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Bwpn == itemid)
12880 {
12881 Bwpn = -1;
12882 game->forced_bwpn = -1;
12883 verifyBWpn();
12884 }
12885
12886
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Awpn == itemid)
12887 {
12888 Awpn = -1;
12889 game->forced_awpn = -1;
12890 verifyAWpn();
12891 }
12892
12893
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Xwpn == itemid)
12894 {
12895 Xwpn = -1;
12896 game->forced_xwpn = -1;
12897 verifyXWpn();
12898 }
12899
12900
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Ywpn == itemid)
12901 {
12902 Ywpn = -1;
12903 game->forced_ywpn = -1;
12904 verifyYWpn();
12905 }
12906 35 }
12907
12908 40746 return ret;
12909 46414 }
12910
12911
12912 1857345 bool HeroClass::doattack()
12913 {
12914
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1857328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
1857345 if(lift_wpn && (liftflags & LIFTFL_DIS_ITEMS))
12915 17 return false;
12916 //int32_t s = BSZ ? 0 : 11;
12917 1857328 int32_t s = (zinit.heroAnimationStyle==las_bszelda) ? 0 : 11;
12918
12919
4/4
✓ Branch 0 taken 469054 times.
✓ Branch 1 taken 1388274 times.
✓ Branch 2 taken 468910 times.
✓ Branch 3 taken 144 times.
1857328 int32_t bugnetid = (directWpn>-1 && itemsbuf[directWpn].family==itype_bugnet) ? directWpn : current_item_id(itype_bugnet);
12920
3/4
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 1857184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 144 times.
1857328 if(attack==wBugNet && bugnetid!=-1)
12921 {
12922
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 138 times.
144 if(++attackclk >= NET_CLK_TOTAL)
12923 6 return false;
12924
12925 138 return true;
12926 }
12927
12928 // Abort attack if attackclk has run out and:
12929 // * the attack is not Hammer, Sword with Spin Scroll, Candle, or Wand, OR
12930 // * you aren't holding down the A button, you're not charging, and/or you're still spinning
12931
12932
6/6
✓ Branch 0 taken 182800 times.
✓ Branch 1 taken 1674384 times.
✓ Branch 2 taken 147316 times.
✓ Branch 3 taken 35484 times.
✓ Branch 4 taken 51479 times.
✓ Branch 5 taken 17731 times.
1926394 if(attackclk>=(spins>0?8:14) && attack!=wHammer &&
12933
12/12
✓ Branch 0 taken 134895 times.
✓ Branch 1 taken 12421 times.
✓ Branch 2 taken 66153 times.
✓ Branch 3 taken 68742 times.
✓ Branch 4 taken 79367 times.
✓ Branch 5 taken 67949 times.
✓ Branch 6 taken 78106 times.
✓ Branch 7 taken 1261 times.
✓ Branch 8 taken 66113 times.
✓ Branch 9 taken 3097 times.
✓ Branch 10 taken 50945 times.
✓ Branch 11 taken 15168 times.
147316 (((attack!=wSword || !current_item(itype_spinscroll) || inlikelike) && attack!=wWand && attack!=wFire && attack!=wCByrna) || !((attack==wSword && isWpnPressed(itype_sword) && spins==0) || charging>0)))
12934 {
12935 95837 tapping=false;
12936 95837 return false;
12937 }
12938
12939
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 1759052 times.
1761347 if(attackclk>29)
12940 {
12941 2295 tapping=false;
12942 2295 return false;
12943 }
12944
12945
4/4
✓ Branch 0 taken 451509 times.
✓ Branch 1 taken 1307543 times.
✓ Branch 2 taken 428579 times.
✓ Branch 3 taken 22930 times.
1759052 int32_t candleid = (directWpn>-1 && itemsbuf[directWpn].family==itype_candle) ? directWpn : current_item_id(itype_candle);
12946
4/4
✓ Branch 0 taken 451509 times.
✓ Branch 1 taken 1307543 times.
✓ Branch 2 taken 451479 times.
✓ Branch 3 taken 30 times.
1759052 int32_t byrnaid = (directWpn>-1 && itemsbuf[directWpn].family==itype_cbyrna) ? directWpn : current_item_id(itype_cbyrna);
12947 // An attack can be "walked out-of" after 8 frames, unless it's:
12948 // * a sword stab
12949 // * a hammer pound
12950 // * a wand thrust
12951 // * a candle thrust
12952 // * a cane thrust
12953 // In which case it should continue.
12954
8/8
✓ Branch 0 taken 68861 times.
✓ Branch 1 taken 1690191 times.
✓ Branch 2 taken 197187 times.
✓ Branch 3 taken 128326 times.
✓ Branch 4 taken 1615288 times.
✓ Branch 5 taken 203229 times.
✓ Branch 6 taken 360429 times.
✓ Branch 7 taken 1254859 times.
2054431 if((attack==wCatching && attackclk>4)||(attack!=wWand && attack!=wSword && attack!=wHammer
12955
5/6
✓ Branch 0 taken 296067 times.
✓ Branch 1 taken 64362 times.
✓ Branch 2 taken 21949 times.
✓ Branch 3 taken 274118 times.
✓ Branch 4 taken 21949 times.
✗ Branch 5 not taken.
360429 && (attack!=wFire || (candleid!=-1 && !(itemsbuf[candleid].wpn)))
12956
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 274088 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
296067 && (attack!=wCByrna || (byrnaid!=-1 && !(itemsbuf[byrnaid].wpn)))
12957
2/2
✓ Branch 0 taken 295379 times.
✓ Branch 1 taken 21291 times.
274118 && (attack != wBugNet) && attackclk>7))
12958 {
12959
8/8
✓ Branch 0 taken 93453 times.
✓ Branch 1 taken 4739 times.
✓ Branch 2 taken 88910 times.
✓ Branch 3 taken 4543 times.
✓ Branch 4 taken 83726 times.
✓ Branch 5 taken 5184 times.
✓ Branch 6 taken 5622 times.
✓ Branch 7 taken 78104 times.
492566 if(DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight())
12960 {
12961 20088 lstep = s;
12962 20088 return false;
12963 }
12964 78104 }
12965
12966
2/2
✓ Branch 0 taken 40923 times.
✓ Branch 1 taken 1602901 times.
1643824 if(charging==0)
12967 {
12968 1602901 lstep=0;
12969 1602901 }
12970
12971 // Work out the sword charge-up delay
12972 1643824 int32_t magiccharge = 192, normalcharge = 64;
12973 1643824 int32_t itemid = current_item_id(itype_chargering);
12974
12975
2/2
✓ Branch 0 taken 1594160 times.
✓ Branch 1 taken 49664 times.
1643824 if(itemid>=0)
12976 {
12977 49664 normalcharge = itemsbuf[itemid].misc1;
12978 49664 magiccharge = itemsbuf[itemid].misc2;
12979 49664 }
12980
12981 1643824 int scrollid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12982 1643824 int scroll2id = current_item_id(attack==wHammer ? itype_quakescroll2 : itype_spinscroll2);
12983
12984 1643824 bool doCharge=true;
12985
3/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 1643674 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 150 times.
1643824 if(z!=0 && fakez != 0)
12986 doCharge=false;
12987
2/2
✓ Branch 0 taken 1254859 times.
✓ Branch 1 taken 388965 times.
1643824 if(attack==wSword)
12988 {
12989
4/4
✓ Branch 0 taken 34916 times.
✓ Branch 1 taken 1219943 times.
✓ Branch 2 taken 613 times.
✓ Branch 3 taken 34303 times.
1254859 if(!(attackclk==SWORDCHARGEFRAME && isWpnPressed(itype_sword)))
12990 1220556 doCharge=false;
12991
2/2
✓ Branch 0 taken 10820 times.
✓ Branch 1 taken 23483 times.
34303 else if(charging<=normalcharge)
12992 {
12993
3/6
✓ Branch 0 taken 23483 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23483 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23483 times.
✗ Branch 5 not taken.
23483 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12994 doCharge=false;
12995 23483 }
12996 1254859 }
12997
2/2
✓ Branch 0 taken 64362 times.
✓ Branch 1 taken 324603 times.
388965 else if(attack==wHammer)
12998 {
12999
4/4
✓ Branch 0 taken 2186 times.
✓ Branch 1 taken 62176 times.
✓ Branch 2 taken 1943 times.
✓ Branch 3 taken 243 times.
64362 if(!(attackclk==HAMMERCHARGEFRAME && isWpnPressed(itype_hammer)))
13000 64119 doCharge=false;
13001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243 times.
243 else if(charging<=normalcharge)
13002 {
13003
4/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
243 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
13004 227 doCharge=false;
13005 243 }
13006 64362 }
13007 else
13008 324603 doCharge=false;
13009
13010 // charging up weapon...
13011
2/2
✓ Branch 0 taken 34319 times.
✓ Branch 1 taken 1609505 times.
1643824 if(doCharge)
13012 {
13013 // Increase charging while holding down button.
13014
3/4
✓ Branch 0 taken 34319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2543 times.
✓ Branch 3 taken 31776 times.
34319 if(spins==0 && charging<magiccharge)
13015 31776 charging++;
13016
13017 // Once a charging threshold is reached, play the sound.
13018
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 34145 times.
34319 if(charging==normalcharge)
13019 {
13020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if(!(itemsbuf[scrollid].flags&item_flag1))
13021 174 paymagiccost(scrollid);
13022 174 sfx(itemsbuf[scrollid].usesound2,pan(x.getInt()));
13023 174 }
13024
2/2
✓ Branch 0 taken 31708 times.
✓ Branch 1 taken 2437 times.
34145 else if(charging==magiccharge)
13025 {
13026
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2434 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
2437 if(scroll2id>-1 && checkbunny(scroll2id) && checkmagiccost(scroll2id))
13027 {
13028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!(itemsbuf[scroll2id].flags&item_flag1))
13029 3 paymagiccost(scroll2id);
13030 3 charging++; // charging>magiccharge signifies a successful supercharge.
13031 3 sfx(itemsbuf[scroll2id].usesound2,pan(x.getInt()));
13032 3 }
13033 2437 }
13034 34319 }
13035
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1609475 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
1609505 else if(attack==wCByrna && byrnaid!=-1)
13036 {
13037
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!(itemsbuf[byrnaid].wpn))
13038 {
13039 attack = wNone;
13040 return startwpn(attackid); // Beam if the Byrna stab animation WASN'T used.
13041 }
13042
13043 30 bool beamcount = false;
13044
13045
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 55 times.
81 for(int32_t i=0; i<Lwpns.Count(); i++)
13046 {
13047 55 weapon *w = ((weapon*)Lwpns.spr(i));
13048
13049
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 4 times.
55 if(w->id==wCByrna)
13050 {
13051 4 beamcount = true;
13052 4 break;
13053 }
13054 51 }
13055
13056 // If beams already deployed, remove them
13057
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
30 if(!attackclk && beamcount)
13058 {
13059 2 return startwpn(attackid); // Remove beams instantly
13060 }
13061
13062 // Otherwise, continue
13063 28 ++attackclk;
13064 28 }
13065 else
13066 {
13067 1609475 ++attackclk;
13068
13069
6/6
✓ Branch 0 taken 4046 times.
✓ Branch 1 taken 1605429 times.
✓ Branch 2 taken 785 times.
✓ Branch 3 taken 3261 times.
✓ Branch 4 taken 485 times.
✓ Branch 5 taken 300 times.
1609475 if(attackclk==SWORDCHARGEFRAME && charging>0 && !tapping) //Signifies a tapped enemy
13070 {
13071 300 ++attackclk; // Won't continue charging
13072 300 charging=0;
13073 300 }
13074
13075 // Faster if spinning.
13076
2/2
✓ Branch 0 taken 1606797 times.
✓ Branch 1 taken 2678 times.
1609475 if(spins>0)
13077 2678 ++attackclk;
13078
13079 // Even faster if hurricane spinning.
13080
2/2
✓ Branch 0 taken 1609043 times.
✓ Branch 1 taken 432 times.
1609475 if(spins>5)
13081 432 attackclk+=2;
13082
13083 // If at a charging threshold, do a charged attack.
13084
5/6
✓ Branch 0 taken 2332 times.
✓ Branch 1 taken 1607143 times.
✓ Branch 2 taken 2332 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2217 times.
✓ Branch 5 taken 115 times.
1609475 if(charging>=normalcharge && (attack!=wSword || attackclk>=SWORDCHARGEFRAME) && !tapping)
13085 {
13086
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(attack==wSword)
13087 {
13088
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3 times.
115 bool super = charging>magiccharge && scroll2id > -1;
13089
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 112 times.
115 int id = super ? scroll2id : scrollid;
13090 115 itemdata const& spinscroll = itemsbuf[id];
13091 115 bool paid = !(spinscroll.flags&item_flag1);
13092
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if(!paid && checkbunny(id) && checkmagiccost(id))
13093 {
13094 paid = true;
13095 paymagiccost(id);
13096 }
13097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(paid)
13098 {
13099 115 currentscroll = id;
13100 115 spins=(spinscroll.misc1*4) + (super ? -3 : 1);
13101 115 attackclk=1;
13102
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 114 times.
115 if(!get_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS))
13103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
2 if(weapon* w = find_first_wtype(wSword))
13104 1 w->reset_wgrids();
13105 115 sfx(spinscroll.usesound,pan(x.getInt()));
13106
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(spinscroll.flags&item_flag1)
13107 paymagiccost(id);
13108 115 }
13109 115 }
13110 else if(attack==wHammer && sideviewhammerpound())
13111 {
13112 bool super = charging>magiccharge && scroll2id > -1;
13113 int id = super ? scroll2id : scrollid;
13114 itemdata const& quakescroll = itemsbuf[id];
13115 bool paid = !(quakescroll.flags&item_flag1);
13116 if(!paid && checkbunny(id) && checkmagiccost(id))
13117 {
13118 paid = true;
13119 paymagiccost(id);
13120 }
13121 if(paid)
13122 {
13123 currentscroll = id;
13124 spins = super ? 2 : 1;
13125 sfx(quakescroll.usesound,pan(x.getInt()));
13126 quakeclk=quakescroll.misc1;
13127
13128 // general area stun
13129 for(int32_t i=0; i<GuyCount(); i++)
13130 {
13131 if(!isflier(GuyID(i)))
13132 {
13133 StunGuy(i,quakescroll.misc2-distance(x,y,GuyX(i),GuyY(i)));
13134 }
13135 }
13136
13137 int hmrid = (directWpn>-1 && itemsbuf[directWpn].family==itype_hammer) ? directWpn : current_item_id(itype_hammer);
13138 int hmrlvl = hmrid < 0 ? 1 : itemsbuf[hmrid].fam_type;
13139 if(hmrlvl < 1) hmrlvl = 1;
13140 int rad = quakescroll.misc2;
13141 for(int pos = 0; pos < 176; ++pos)
13142 {
13143 if(distance(x,y,COMBOX(pos),COMBOY(pos)) > rad) continue;
13144 for(int lyr = 0; lyr < 7; ++lyr)
13145 {
13146 int cid = FFCore.tempScreens[lyr]->data[pos];
13147 newcombo const& cmb = combobuf[cid];
13148 if(cmb.triggerflags[2] & ((super?combotriggerSQUAKESTUN:0)|combotriggerQUAKESTUN))
13149 {
13150 if((cmb.triggerflags[0]&combotriggerINVERTMINMAX)
13151 ? hmrlvl <= cmb.triggerlevel
13152 : hmrlvl >= cmb.triggerlevel)
13153 do_trigger_combo(lyr,pos);
13154 }
13155 }
13156 }
13157 word c = tmpscr->numFFC();
13158 for(int ff = 0; ff < c; ++ff)
13159 {
13160 ffcdata& ffc = tmpscr->ffcs[ff];
13161 newcombo const& cmb = combobuf[ffc.data];
13162 if(distance(x,y,ffc.x,ffc.y) > rad) continue;
13163 if(cmb.triggerflags[2] & ((super?combotriggerSQUAKESTUN:0)|combotriggerQUAKESTUN))
13164 {
13165 if((cmb.triggerflags[0]&combotriggerINVERTMINMAX)
13166 ? hmrlvl <= cmb.triggerlevel
13167 : hmrlvl >= cmb.triggerlevel)
13168 do_trigger_combo_ffc(ff);
13169 }
13170 }
13171 }
13172 }
13173 115 }
13174
6/6
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 1605289 times.
✓ Branch 2 taken 3586 times.
✓ Branch 3 taken 485 times.
✓ Branch 4 taken 347 times.
✓ Branch 5 taken 3239 times.
1609360 else if(tapping && attackclk<SWORDCHARGEFRAME && charging<magiccharge)
13175 3239 charging++;
13176
13177
7/8
✓ Branch 0 taken 21550 times.
✓ Branch 1 taken 1587925 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1587925 times.
✓ Branch 4 taken 25736 times.
✓ Branch 5 taken 1562189 times.
✓ Branch 6 taken 901362 times.
✓ Branch 7 taken 708113 times.
1609475 if(!isWpnPressed(attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword))
13178 708113 charging=0;
13179
13180
2/2
✓ Branch 0 taken 1581709 times.
✓ Branch 1 taken 27766 times.
1609475 if(attackclk>=SWORDCHARGEFRAME)
13181 27766 tapping = false;
13182 }
13183
13184
7/8
✓ Branch 0 taken 125316 times.
✓ Branch 1 taken 1518506 times.
✓ Branch 2 taken 1801 times.
✓ Branch 3 taken 123515 times.
✓ Branch 4 taken 1801 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 47 times.
✓ Branch 7 taken 1754 times.
1643822 if(attackclk==1 && attack==wFire && candleid!=-1 && !(itemsbuf[candleid].wpn))
13185 {
13186 1754 return startwpn(attackid); // Flame if the Candle stab animation WASN'T used.
13187 }
13188
13189 1642068 int32_t crossid = current_item_id(itype_crossscroll); //has Cross Beams scroll
13190
13191
11/14
✓ Branch 0 taken 1542300 times.
✓ Branch 1 taken 99768 times.
✓ Branch 2 taken 113923 times.
✓ Branch 3 taken 1428377 times.
✓ Branch 4 taken 450 times.
✓ Branch 5 taken 113473 times.
✓ Branch 6 taken 450 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✓ Branch 9 taken 438 times.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
1642068 if(attackclk==13 || (attackclk==7 && spins>1 && attack != wHammer && crossid >=0 && checkbunny(crossid) && checkmagiccost(crossid)))
13192 {
13193
13194
4/4
✓ Branch 0 taken 18073 times.
✓ Branch 1 taken 81707 times.
✓ Branch 2 taken 14934 times.
✓ Branch 3 taken 3139 times.
99780 int32_t wpnid = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? directWpn : current_item_id(itype_sword);
13195
2/2
✓ Branch 0 taken 99383 times.
✓ Branch 1 taken 397 times.
99780 int64_t templife = wpnid>=0? itemsbuf[wpnid].misc1 : 0;
13196
13197
4/4
✓ Branch 0 taken 99383 times.
✓ Branch 1 taken 397 times.
✓ Branch 2 taken 26727 times.
✓ Branch 3 taken 72656 times.
99780 if(wpnid>=0 && itemsbuf[wpnid].flags & item_flag1)
13198 {
13199 72656 templife=templife*game->get_maxlife();
13200 72656 templife=templife/100;
13201 72656 }
13202 else
13203 {
13204 27124 templife*=game->get_hp_per_heart();
13205 }
13206
13207
2/2
✓ Branch 0 taken 37050 times.
✓ Branch 1 taken 62730 times.
99780 bool normalbeam = (int64_t(game->get_life())+(get_qr(qr_QUARTERHEART)?((game->get_hp_per_heart()/4)-1):((game->get_hp_per_heart()/2)-1))>=templife);
13208 99780 int32_t perilid = current_item_id(itype_perilscroll);
13209
3/4
✓ Branch 0 taken 7415 times.
✓ Branch 1 taken 92365 times.
✓ Branch 2 taken 7415 times.
✗ Branch 3 not taken.
99851 bool perilbeam = (perilid>=0 && wpnid>=0 && game->get_life()<=itemsbuf[perilid].misc1*game->get_hp_per_heart()
13210
3/4
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 7344 times.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
7415 && checkbunny(perilid) && checkmagiccost(perilid)
13211 // Must actually be able to shoot sword beams
13212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 && ((itemsbuf[wpnid].flags & item_flag1)
13213
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 70 times.
71 || itemsbuf[wpnid].misc1 <= game->get_maxlife()/game->get_hp_per_heart()));
13214
13215
4/4
✓ Branch 0 taken 84669 times.
✓ Branch 1 taken 15111 times.
✓ Branch 2 taken 531 times.
✓ Branch 3 taken 84138 times.
99780 if(attack==wSword && !tapping)
13216 {
13217
4/4
✓ Branch 0 taken 84069 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 19928 times.
✓ Branch 3 taken 64141 times.
84138 if(perilbeam || normalbeam)
13218 {
13219
1/2
✓ Branch 0 taken 19997 times.
✗ Branch 1 not taken.
19997 if(attackclk==7)
13220 paymagiccost(crossid); // Pay the Cross Beams magic cost.
13221
13222
3/4
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 19928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 69 times.
19997 if(perilbeam && !normalbeam)
13223 69 paymagiccost(perilid); // Pay the Peril Beam magic cost.
13224
13225 // TODO: Something that would be cheap but disgraceful to hack in at this point is
13226 // a way to make the peril/cross beam item's power stat influence the strength
13227 // of the peril/cross beam...
13228 19997 startwpn(attackid);
13229 19997 }
13230 64141 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
13231 84138 }
13232
13233
2/2
✓ Branch 0 taken 97943 times.
✓ Branch 1 taken 1837 times.
99780 if(attack==wWand)
13234 1837 startwpn(attackid); // Flame if the Wand stab animation WAS used (it always is).
13235
13236
5/6
✓ Branch 0 taken 1303 times.
✓ Branch 1 taken 98477 times.
✓ Branch 2 taken 1303 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1256 times.
✓ Branch 5 taken 47 times.
99780 if(attack==wFire && candleid!=-1 && itemsbuf[candleid].wpn) // Flame if the Candle stab animation WAS used.
13237 47 startwpn(attackid);
13238
13239
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 99778 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
99780 if(attack==wCByrna && byrnaid!=-1 && itemsbuf[byrnaid].wpn) // Beam if the Byrna stab animation WAS used.
13240 2 startwpn(attackid);
13241 99780 }
13242
13243
2/2
✓ Branch 0 taken 1543182 times.
✓ Branch 1 taken 98886 times.
1642068 if(attackclk==14)
13244 98886 lstep = s;
13245
13246 1642068 return true;
13247 1762205 }
13248
13249 26890108 bool HeroClass::can_attack()
13250 {
13251
4/4
✓ Branch 0 taken 19886 times.
✓ Branch 1 taken 26870222 times.
✓ Branch 2 taken 4006 times.
✓ Branch 3 taken 15880 times.
26890108 if(lift_wpn && (liftflags & LIFTFL_DIS_ITEMS))
13252 15880 return false;
13253
4/4
✓ Branch 0 taken 26549850 times.
✓ Branch 1 taken 324378 times.
✓ Branch 2 taken 17927960 times.
✓ Branch 3 taken 8621890 times.
26874228 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
13254
4/6
✓ Branch 0 taken 26874228 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26607134 times.
✓ Branch 3 taken 267094 times.
✓ Branch 4 taken 26607134 times.
✗ Branch 5 not taken.
28277800 if(action==hopping || action==swimming || action==freeze || action==sideswimfreeze
13255
5/8
✓ Branch 0 taken 26607134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26607134 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26607134 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26600226 times.
✓ Branch 7 taken 6908 times.
26607134 || lstunclock > 0 || is_conveyor_stunned || spins>0 || usingActiveShield()
13256
3/4
✓ Branch 0 taken 26600226 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23276738 times.
✓ Branch 3 taken 3323488 times.
26600226 || ((action==attacking||action==sideswimattacking)
13257
2/2
✓ Branch 0 taken 740800 times.
✓ Branch 1 taken 25859426 times.
26600226 && ((attack!=wSword && attack!=wWand) || !(itemsbuf[currentSwordOrWand].flags & item_flag5))
13258
2/2
✓ Branch 0 taken 26522198 times.
✓ Branch 1 taken 662772 times.
26600226 && charging!=0))
13259 {
13260 1677574 return false;
13261 }
13262
13263 26522198 int32_t r = (isdungeon()) ? 16 : 0;
13264 26522198 int32_t r2 = get_qr(qr_NOBORDER) ? 0 : 8;
13265
13266
4/5
✓ Branch 0 taken 7297558 times.
✓ Branch 1 taken 19224640 times.
✓ Branch 2 taken 8484302 times.
✓ Branch 3 taken 10740338 times.
✗ Branch 4 not taken.
26522198 if(!get_qr(qr_ITEMSONEDGES)) switch(dir)
13267 {
13268 case up:
13269 case down:
13270
2/2
✓ Branch 0 taken 8184290 times.
✓ Branch 1 taken 300012 times.
8484302 return !(y<(r2+r) || y>(160-r-r2));
13271
13272 case left:
13273 case right:
13274
2/2
✓ Branch 0 taken 10451350 times.
✓ Branch 1 taken 288988 times.
10740338 return !(x<(r2+r) || x>(240-r-r2));
13275 }
13276
13277 7297558 return true;
13278 28215652 }
13279
13280 16775 bool isRaftFlag(int32_t flag)
13281 {
13282
4/4
✓ Branch 0 taken 8791 times.
✓ Branch 1 taken 7984 times.
✓ Branch 2 taken 255 times.
✓ Branch 3 taken 8536 times.
16775 return (flag==mfRAFT || flag==mfRAFT_BRANCH || flag==mfRAFT_BOUNCE);
13283 }
13284
13285 7508760 void handle_lens_triggers(int32_t l_id)
13286 {
13287
2/2
✓ Branch 0 taken 7502501 times.
✓ Branch 1 taken 6259 times.
7508760 bool enabled = l_id >= 0 && (itemsbuf[l_id].flags & item_flag6);
13288
2/2
✓ Branch 0 taken 7508760 times.
✓ Branch 1 taken 52561320 times.
60070080 for(auto layer = 0; layer < 7; ++layer)
13289 {
13290 52561320 mapscr* tmp = FFCore.tempScreens[layer];
13291
2/2
✓ Branch 0 taken 9250792320 times.
✓ Branch 1 taken 52561320 times.
9303353640 for(auto pos = 0; pos < 176; ++pos)
13292 {
13293 9250792320 newcombo const& cmb = combobuf[tmp->data[pos]];
13294
4/4
✓ Branch 0 taken 280896 times.
✓ Branch 1 taken 9250511424 times.
✓ Branch 2 taken 9250792134 times.
✓ Branch 3 taken 186 times.
9250792320 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
13295 9250511424 : (cmb.triggerflags[1] & combotriggerLENSOFF))
13296 {
13297 186 do_trigger_combo(layer, pos);
13298 186 }
13299 9250792320 }
13300 52561320 }
13301
2/2
✓ Branch 0 taken 6537625 times.
✓ Branch 1 taken 971135 times.
7508760 if (!get_qr(qr_OLD_FFC_FUNCTIONALITY))
13302 {
13303 971135 word c = tmpscr->numFFC();
13304
2/2
✓ Branch 0 taken 2948374 times.
✓ Branch 1 taken 971135 times.
3919509 for(word i=0; i<c; i++)
13305 {
13306 2948374 ffcdata& ffc = tmpscr->ffcs[i];
13307 2948374 newcombo const& cmb = combobuf[ffc.data];
13308
3/4
✓ Branch 0 taken 1596 times.
✓ Branch 1 taken 2946778 times.
✓ Branch 2 taken 2948374 times.
✗ Branch 3 not taken.
2948374 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
13309 2946778 : (cmb.triggerflags[1] & combotriggerLENSOFF))
13310 {
13311 do_trigger_combo_ffc(i);
13312 }
13313 2948374 }
13314 971135 }
13315 7508760 }
13316
13317 13572285 void do_lens()
13318 {
13319
2/2
✓ Branch 0 taken 6063525 times.
✓ Branch 1 taken 7508760 times.
13572285 if ( FFCore.getQuestHeaderInfo(vZelda) < 0x250 ) //2.10 or earlier
13320 {
13321 6063525 do_210_lens();
13322 6063525 return;
13323 }
13324
13325 7508760 int32_t wpnPressed = getWpnPressed(itype_lens);
13326
6/6
✓ Branch 0 taken 6256 times.
✓ Branch 1 taken 7502504 times.
✓ Branch 2 taken 375 times.
✓ Branch 3 taken 7502129 times.
✓ Branch 4 taken 390142 times.
✓ Branch 5 taken 7111987 times.
7508760 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>0 ? wpnPressed : Hero.getLastLensID()>0 ? Hero.getLastLensID() : current_item_id(itype_lens);
13327
2/2
✓ Branch 0 taken 6037298 times.
✓ Branch 1 taken 1471462 times.
7508760 if(itemid >= 0)
13328 {
13329
8/10
✓ Branch 0 taken 5343 times.
✓ Branch 1 taken 1466119 times.
✓ Branch 2 taken 5343 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 693 times.
✓ Branch 5 taken 4650 times.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 166 times.
✓ Branch 9 taken 527 times.
1471462 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkbunny(itemid) && checkmagiccost(itemid))
13330 {
13331
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 209 times.
527 if(lensid<0)
13332 {
13333 209 lensid=itemid;
13334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209 times.
209 if(itemsbuf[itemid].family == itype_lens)
13335 209 Hero.setLastLensID(itemid);
13336
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 12 times.
209 if(get_qr(qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
13337 209 }
13338
13339 527 paymagiccost(itemid, true); //Needs to ignore timer cause lensclk is our timer.
13340
13341
2/10
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 527 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
527 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(FFCore.doscript(ScriptType::Item, itemid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
13342 {
13343 //clear the item script stack for a new script
13344 int i = itemid;
13345 FFCore.reset_script_engine_data(ScriptType::Item, i);
13346 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
13347 did_scriptl=true;
13348 }
13349
13350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
13351 527 else lensclk = 12;
13352 527 }
13353 else
13354 {
13355 1470935 did_scriptl=false;
13356
2/2
✓ Branch 0 taken 1465203 times.
✓ Branch 1 taken 5732 times.
1470935 if(!lensclk)
13357 {
13358
13359
2/2
✓ Branch 0 taken 1464997 times.
✓ Branch 1 taken 206 times.
1465203 if(lensid>-1)
13360 {
13361 206 lensid=-1;
13362 206 lensclk = 0;
13363
13364
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 11 times.
206 if(get_qr(qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
13365 206 }
13366 1465203 }
13367 }
13368 1471462 }
13369 7508760 handle_lens_triggers(lensid);
13370 13572285 }
13371
13372 6063525 void do_210_lens()
13373 {
13374 6063525 int32_t wpnPressed = getWpnPressed(itype_lens);
13375
4/4
✓ Branch 0 taken 3334 times.
✓ Branch 1 taken 6060191 times.
✓ Branch 2 taken 487 times.
✓ Branch 3 taken 6059704 times.
6063525 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>-1 ? wpnPressed : current_item_id(itype_lens);
13376
2/2
✓ Branch 0 taken 1226986 times.
✓ Branch 1 taken 4836539 times.
6063525 if(itemid<0)
13377 4836539 return;
13378
13379
7/8
✓ Branch 0 taken 3343 times.
✓ Branch 1 taken 1223643 times.
✓ Branch 2 taken 3343 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 2821 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 515 times.
1226986 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkmagiccost(itemid))
13380 {
13381
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 480 times.
515 if(lensid<0)
13382 {
13383 480 lensid=itemid;
13384
13385
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(get_qr(qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
13386 480 }
13387
13388 515 paymagiccost(itemid, true);
13389
13390
2/10
✓ Branch 0 taken 515 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 515 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
515 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(FFCore.doscript(ScriptType::Item, itemid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
13391 {
13392 //clear the item script stack for a new script
13393 int i = itemid;
13394 FFCore.reset_script_engine_data(ScriptType::Item, i);
13395 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
13396 did_scriptl=true;
13397 }
13398
13399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515 times.
515 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
13400 515 else lensclk = 12;
13401 515 }
13402 else
13403 {
13404 1226471 did_scriptl=false;
13405
13406
7/8
✓ Branch 0 taken 3299 times.
✓ Branch 1 taken 1223172 times.
✓ Branch 2 taken 2821 times.
✓ Branch 3 taken 478 times.
✓ Branch 4 taken 2821 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2820 times.
✓ Branch 7 taken 1 times.
1226471 if(lensid>-1 && !(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && checkmagiccost(itemid)))
13407 {
13408 479 lensid=-1;
13409 479 lensclk = 0;
13410
13411
1/2
✓ Branch 0 taken 479 times.
✗ Branch 1 not taken.
479 if(get_qr(qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
13412 479 }
13413 }
13414 6063525 }
13415
13416 14081 void HeroClass::do_hopping()
13417 {
13418 14081 do_lens();
13419
13420
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 13527 times.
14081 if(hopclk==0xFF) //|| (diagonalMovement && hopclk >= 0xFF) )) // swimming
13421 //Possible fix for exiting water in diagonal movement. -Z
13422 {
13423 554 int32_t flippers_id = current_item_id(itype_flippers);
13424
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 550 times.
554 if(diveclk>0)
13425 {
13426 4 --diveclk;
13427
2/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if(flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag2 && DrunkrAbtn()) //Cancellable Diving -V
13428 {
13429 diveclk = itemsbuf[flippers_id].misc2;
13430 }
13431 4 }
13432
2/2
✓ Branch 0 taken 548 times.
✓ Branch 1 taken 2 times.
550 else if(DrunkrAbtn())
13433 {
13434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag1);
13435 2 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
13436
13437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(global_diving==screen_diving)
13438
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
13439 2 }
13440
13441
6/8
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 156 times.
✓ Branch 3 taken 398 times.
✓ Branch 4 taken 156 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 156 times.
554 if((!(x.getInt()&7) && !(y.getInt()&7)) || (diagonalMovement||NO_GRIDLOCK))
13442 {
13443 398 SetSwim();
13444 398 hopclk = 0;
13445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (!IsSideSwim())
13446 {
13447 398 charging = attackclk = 0;
13448 398 tapping = false;
13449 398 }
13450 398 }
13451 else
13452 {
13453 156 herostep();
13454
13455
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
156 if(!isDiving() || (frame&1))
13456 {
13457
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 77 times.
156 switch(dir)
13458 {
13459 case up:
13460 42 y -= 1;
13461 42 break;
13462
13463 case down:
13464 7 y += 1;
13465 7 break;
13466
13467 case left:
13468 30 x -= 1;
13469 30 break;
13470
13471 case right:
13472 77 x += 1;
13473 77 break;
13474 }
13475 156 }
13476 }
13477 554 }
13478 else // hopping in or out (need to separate the cases...)
13479 {
13480
4/6
✓ Branch 0 taken 12509 times.
✓ Branch 1 taken 1018 times.
✓ Branch 2 taken 12509 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12509 times.
13527 if((diagonalMovement||NO_GRIDLOCK))
13481 {
13482
2/2
✓ Branch 0 taken 643 times.
✓ Branch 1 taken 375 times.
1018 if(hopclk==1) //hopping out
13483 //>= 1 possible fix for getting stuck on land edges.
13484 //No, this is not a clock. it's a type. 1 == out, 2 == in.
13485 {
13486
1/2
✓ Branch 0 taken 375 times.
✗ Branch 1 not taken.
375 if(hopdir!=-1) dir=hopdir;
13487
13488 375 landswim=0;
13489
13490
2/2
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 101 times.
375 if(dir==up)
13491 {
13492 101 herostep();
13493 101 herostep();
13494 101 int32_t sidestep=0;
13495
13496
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 101 times.
101 if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13497 sidestep=1;
13498
3/6
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101 times.
✗ Branch 5 not taken.
101 else if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13499 sidestep=2;
13500
13501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if(sidestep==1) x++;
13502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 else if(sidestep==2) x--;
13503 101 else y--;
13504
13505
3/4
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 8 times.
101 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
13506 {
13507 8 hopclk=0;
13508 8 diveclk=0;
13509 8 action=none; FFCore.setHeroAction(none);
13510 8 hopdir=-1;
13511 8 }
13512 101 }
13513
13514
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 72 times.
375 if(dir==down)
13515 {
13516 72 herostep();
13517 72 herostep();
13518 72 int32_t sidestep=0;
13519
13520
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 72 times.
72 if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
13521 sidestep=1;
13522
3/6
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
72 else if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
13523 sidestep=2;
13524
13525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(sidestep==1) x++;
13526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 else if(sidestep==2) x--;
13527 72 else y++;
13528
13529
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
72 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
13530 {
13531 6 hopclk=0;
13532 6 diveclk=0;
13533 6 action=none; FFCore.setHeroAction(none);
13534 6 hopdir=-1;
13535 6 }
13536 72 }
13537
13538
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 57 times.
375 if(dir==left)
13539 {
13540 57 herostep();
13541 57 herostep();
13542 57 int32_t sidestep=0;
13543
13544
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 57 times.
57 if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
13545 sidestep=1;
13546
3/6
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 57 times.
✗ Branch 5 not taken.
57 else if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
13547 sidestep=2;
13548
13549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(sidestep==1) y++;
13550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 else if(sidestep==2) y--;
13551 57 else x--;
13552
13553
3/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 4 times.
57 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
13554 {
13555 4 hopclk=0;
13556 4 diveclk=0;
13557 4 action=none; FFCore.setHeroAction(none);
13558 4 hopdir=-1;
13559 4 }
13560 57 }
13561
13562
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 145 times.
375 if(dir==right)
13563 {
13564 145 herostep();
13565 145 herostep();
13566 145 int32_t sidestep=0;
13567
13568
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 145 times.
145 if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
13569 sidestep=1;
13570
3/6
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145 times.
✓ Branch 4 taken 145 times.
✗ Branch 5 not taken.
145 else if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
13571 sidestep=2;
13572
13573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
145 if(sidestep==1) y++;
13574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
145 else if(sidestep==2) y--;
13575 145 else x++;
13576
13577
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 134 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
145 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
13578 {
13579 11 hopclk=0;
13580 11 diveclk=0;
13581 11 action=none; FFCore.setHeroAction(none);
13582 11 hopdir=-1;
13583 11 }
13584 145 }
13585 375 }
13586
13587
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 643 times.
1018 if(hopclk==2) //hopping in
13588 {
13589 643 landswim=0;
13590
13591
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 89 times.
643 if(dir==up)
13592 {
13593 89 herostep();
13594 89 herostep();
13595 89 int32_t sidestep=0;
13596
13597
6/6
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 39 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 88 times.
89 if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13598 1 sidestep=1;
13599
4/6
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
88 else if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13600 sidestep=2;
13601
13602
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 88 times.
89 if(sidestep==1) x++;
13603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 else if(sidestep==2) x--;
13604 88 else y--;
13605
13606
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 4 times.
89 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
13607 {
13608 4 hopclk=0xFF;
13609 4 diveclk=0;
13610 4 SetSwim();
13611 4 }
13612 89 }
13613
13614
2/2
✓ Branch 0 taken 501 times.
✓ Branch 1 taken 142 times.
643 if(dir==down)
13615 {
13616 142 herostep();
13617 142 herostep();
13618 142 int32_t sidestep=0;
13619
13620
3/6
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 142 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 142 times.
142 if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
13621 sidestep=1;
13622
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 142 times.
✗ Branch 5 not taken.
142 else if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
13623 sidestep=2;
13624
13625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if(sidestep==1) x++;
13626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if(sidestep==2) x--;
13627 142 else y++;
13628
13629
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
142 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
13630 {
13631 hopclk=0xFF;
13632 diveclk=0;
13633 SetSwim();
13634 if (!IsSideSwim()) reset_swordcharge();
13635 }
13636 142 }
13637
13638
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 133 times.
643 if(dir==left)
13639 {
13640 133 herostep();
13641 133 herostep();
13642 133 int32_t sidestep=0;
13643
13644
4/6
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
133 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
13645 sidestep=1;
13646
4/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
133 else if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
13647 sidestep=2;
13648
13649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 if(sidestep==1) y++;
13650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 else if(sidestep==2) y--;
13651 133 else x--;
13652
13653
4/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 95 times.
133 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
13654 {
13655 7 hopclk=0xFF;
13656 7 diveclk=0;
13657 7 SetSwim();
13658 7 }
13659 133 }
13660
13661
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 279 times.
643 if(dir==right)
13662 {
13663 279 herostep();
13664 279 herostep();
13665
13666 279 int32_t sidestep=0;
13667
13668
4/6
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 279 times.
279 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
13669 sidestep=1;
13670
4/6
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 279 times.
✗ Branch 5 not taken.
279 else if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
13671 sidestep=2;
13672
13673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 if(sidestep==1) y++;
13674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 else if(sidestep==2) y--;
13675 279 else x++;
13676
13677
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
279 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
13678 {
13679 5 hopclk=0xFF;
13680 5 diveclk=0;
13681 5 SetSwim();
13682 5 }
13683 279 }
13684 643 }
13685
13686 1018 }
13687 else
13688 {
13689
7/8
✓ Branch 0 taken 4823 times.
✓ Branch 1 taken 7686 times.
✓ Branch 2 taken 4823 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3622 times.
✓ Branch 5 taken 1201 times.
✓ Branch 6 taken 640 times.
✓ Branch 7 taken 7046 times.
12509 if((dir<left ? !(x.getInt()&7) && !(y.getInt()&15) : !(x.getInt()&15) && !(y.getInt()&7)))
13690 {
13691 1201 action=none; FFCore.setHeroAction(none);
13692 1201 hopclk = 0;
13693 1201 diveclk = 0;
13694
13695
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 625 times.
1201 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+8), currmap, currscr, -1, x.getInt(),y.getInt()+8, true, false))
13696 {
13697 // hopped in
13698 625 SetSwim();
13699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625 times.
625 if (!IsSideSwim()) attackclk = charging = spins = 0;
13700 625 }
13701 1201 }
13702 else
13703 {
13704 11308 herostep();
13705 11308 herostep();
13706
13707
2/2
✓ Branch 0 taken 10642 times.
✓ Branch 1 taken 666 times.
11308 if(++hero_count>(16*hero_animation_speed))
13708 666 hero_count=0;
13709
13710 11308 int32_t xofs2 = x.getInt()&15;
13711 11308 int32_t yofs2 = y.getInt()&15;
13712 11308 int32_t s = 1 + (frame&1);
13713
13714
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 2606 times.
✓ Branch 3 taken 3402 times.
✓ Branch 4 taken 3644 times.
11308 switch(dir)
13715 {
13716 case up:
13717
4/4
✓ Branch 0 taken 1173 times.
✓ Branch 1 taken 483 times.
✓ Branch 2 taken 1167 times.
✓ Branch 3 taken 6 times.
1656 if(yofs2<3 || yofs2>13) --y;
13718 1167 else y-=s;
13719
13720 1656 break;
13721
13722 case down:
13723
4/4
✓ Branch 0 taken 2152 times.
✓ Branch 1 taken 454 times.
✓ Branch 2 taken 356 times.
✓ Branch 3 taken 1796 times.
2606 if(yofs2<3 || yofs2>13) ++y;
13724 1796 else y+=s;
13725
13726 2606 break;
13727
13728 case left:
13729
4/4
✓ Branch 0 taken 2966 times.
✓ Branch 1 taken 436 times.
✓ Branch 2 taken 598 times.
✓ Branch 3 taken 2368 times.
3402 if(xofs2<3 || xofs2>13) --x;
13730 2368 else x-=s;
13731
13732 3402 break;
13733
13734 case right:
13735
4/4
✓ Branch 0 taken 3009 times.
✓ Branch 1 taken 635 times.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 2517 times.
3644 if(xofs2<3 || xofs2>13) ++x;
13736 2517 else x+=s;
13737
13738 3644 break;
13739 }
13740 }
13741 }
13742 }
13743 14081 }
13744
13745 113150 void HeroClass::do_rafting()
13746 {
13747
13748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 if(toogam)
13749 {
13750 action=none; FFCore.setHeroAction(none);
13751 return;
13752 }
13753
13754 113150 FFCore.setHeroAction(rafting);
13755
13756 113150 do_lens();
13757
13758 113150 herostep();
13759
13760 //Calculate rafting speed
13761 113150 int32_t raft_item = current_item_id(itype_raft);
13762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 int32_t raft_step = (raft_item < 0 ? 1 : itemsbuf[raft_item].misc1);
13763 113150 raft_step = vbound(raft_step, -8, 5);
13764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 int32_t raft_time = raft_step < 0 ? 1<<(-raft_step) : 1;
13765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 if(raft_step < 0) raft_step = 1;
13766 113150 int32_t step_inc = 1 << (raft_step - 1);
13767 // Fix position
13768
1/2
✓ Branch 0 taken 113150 times.
✗ Branch 1 not taken.
113150 if(raft_step > 1)
13769 {
13770 if(x.getInt() & (step_inc-1))
13771 {
13772 x = x.getInt() & ~(step_inc-1);
13773 }
13774 if(y.getInt() & (step_inc-1))
13775 {
13776 y = y.getInt() & ~(step_inc-1);
13777 }
13778 }
13779 // Inc clock, check if we need to move this frame
13780 113150 ++raftclk;
13781
2/4
✓ Branch 0 taken 113150 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113150 times.
113150 if((raftclk % raft_time) || raft_step == 0) return; //No movement this frame
13782
13783
4/4
✓ Branch 0 taken 54339 times.
✓ Branch 1 taken 58811 times.
✓ Branch 2 taken 46510 times.
✓ Branch 3 taken 7829 times.
120836 if(!(x.getInt()&15) && !(y.getInt()&15))
13784 {
13785 // this sections handles switching to raft branches
13786
3/4
✓ Branch 0 taken 7575 times.
✓ Branch 1 taken 254 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7575 times.
7829 if((MAPFLAG(x,y)==mfRAFT_BRANCH||MAPCOMBOFLAG(x,y)==mfRAFT_BRANCH))
13787 {
13788
7/8
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 139 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 35 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
254 if(dir!=down && DrunkUp() && (isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
13789 {
13790 35 dir = up;
13791 35 goto skip;
13792 }
13793
13794
7/8
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 112 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 48 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
219 if(dir!=up && DrunkDown() && (isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
13795 {
13796 48 dir = down;
13797 48 goto skip;
13798 }
13799
13800
7/8
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 98 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 31 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
171 if(dir!=right && DrunkLeft() && (isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
13801 {
13802 31 dir = left;
13803 31 goto skip;
13804 }
13805
13806
7/8
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 41 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
140 if(dir!=left && DrunkRight() && (isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
13807 {
13808 29 dir = right;
13809 29 goto skip;
13810 }
13811 111 }
13812
2/4
✓ Branch 0 taken 7575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7575 times.
7575 else if((MAPFLAG(x,y)==mfRAFT_BOUNCE||MAPCOMBOFLAG(x,y)==mfRAFT_BOUNCE))
13813 {
13814 if(dir == left) dir = right;
13815 else if(dir == right) dir = left;
13816 else if(dir == up) dir = down;
13817 else if(dir == down) dir = up;
13818 }
13819
13820
13821
4/4
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 6304 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 1371 times.
7686 if(!isRaftFlag(nextflag(x,y,dir,false))&&!isRaftFlag(nextflag(x,y,dir,true)))
13822 {
13823
2/2
✓ Branch 0 taken 739 times.
✓ Branch 1 taken 632 times.
1371 if(dir<left) //going up or down
13824 {
13825
3/4
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 269 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 470 times.
739 if((isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
13826 269 dir=right;
13827
3/4
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 241 times.
470 else if((isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
13828 229 dir=left;
13829
4/4
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 16 times.
241 else if(y>0 && y<160)
13830 {
13831 210 action=none; FFCore.setHeroAction(none);
13832 210 x = x.getInt();
13833 210 y = y.getInt();
13834 210 }
13835 739 }
13836 else //going left or right
13837 {
13838
3/4
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 243 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 389 times.
632 if((isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
13839 243 dir=down;
13840
3/4
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 242 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 147 times.
389 else if((isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
13841 242 dir=up;
13842
4/4
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 145 times.
147 else if(x>0 && x<240)
13843 {
13844 145 action=none; FFCore.setHeroAction(none);
13845 145 x = x.getInt();
13846 145 y = y.getInt();
13847 145 }
13848 }
13849 1371 }
13850 7686 }
13851
13852 skip:
13853
13854
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 25101 times.
✓ Branch 2 taken 24965 times.
✓ Branch 3 taken 29470 times.
✓ Branch 4 taken 33614 times.
113150 switch(dir)
13855 {
13856 case up:
13857
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 25092 times.
25101 if(x.getInt()&15)
13858 {
13859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(x.getInt()&8)
13860 x++;
13861 9 else x--;
13862 9 }
13863 25092 else y -= step_inc;
13864
13865 25101 break;
13866
13867 case down:
13868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24965 times.
24965 if(x.getInt()&15)
13869 {
13870 if(x.getInt()&8)
13871 x++;
13872 else x--;
13873 }
13874 24965 else y += step_inc;
13875
13876 24965 break;
13877
13878 case left:
13879
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 29464 times.
29470 if(y.getInt()&15)
13880 {
13881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (get_qr(qr_BETTER_RAFT_2))
13882 {
13883 if ((y.getInt() % 16) < 4) y--;
13884 else y++;
13885 }
13886 else
13887 {
13888
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(y.getInt()&8)
13889 6 y++;
13890 else y--;
13891 }
13892 6 }
13893 29464 else x -= step_inc;
13894
13895 29470 break;
13896
13897 case right:
13898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33614 times.
33614 if(y.getInt()&15)
13899 {
13900 if (get_qr(qr_BETTER_RAFT_2))
13901 {
13902 if ((y.getInt() % 16) <= 4) y--;
13903 else y++;
13904 }
13905 else
13906 {
13907 if(y.getInt()&8)
13908 y++;
13909 else y--;
13910 }
13911 }
13912 33614 else x += step_inc;
13913
13914 33614 break;
13915 }
13916 113150 }
13917
13918 271 bool HeroClass::try_hover()
13919 {
13920
6/10
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 269 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
271 if(hoverclk <= 0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
13921 {
13922 2 int32_t itemid = current_item_id(itype_hoverboots);
13923
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hoverclk < 0)
13924 hoverclk = -hoverclk;
13925 else
13926 {
13927 2 fall = fakefall = jumping = 0;
13928
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].misc1)
13929 2 hoverclk = itemsbuf[itemid].misc1;
13930 else
13931 {
13932 hoverclk = 1;
13933 hoverflags |= HOV_INF;
13934 }
13935
13936
13937 2 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
13938 }
13939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(itemsbuf[itemid].wpn)
13940
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 decorations.add(new dHover(x, y, dHOVER, 0));
13941 2 return true;
13942 }
13943 269 return false;
13944 271 }
13945
13946 //Returns bitwise; lower 8 are dir pulled in, next 16 are combo ID, 25th bit is bool for if can be resisted
13947 //Returns '-1' if not being pulled
13948 //Returns '-2' if should be falling in
13949 53887063 int32_t HeroClass::check_pitslide(bool ignore_hover)
13950 {
13951 //Pitfall todo -Emily
13952 //Iron boots; can't fight slipping, 2px/frame
13953 //Scripted variables to read pull dir/clk (clk only for non-hero)
13954 //Implement falling for all sprite types (npc AI)
13955 // Fall/slipping tiles for enemies
13956 // Fall/slipping SFX for enemies
13957 // Fall SFX for items/weapons
13958 // Weapons/Misc sprite shared for falling items/weapons
13959 //Maybe slip SFX for Hero?
13960 // Weapons/Misc sprite override for falling sprite?
13961 //Update std.zh with relevant new stuff
13962
2/2
✓ Branch 0 taken 1409149 times.
✓ Branch 1 taken 52477914 times.
53887063 if(can_pitfall(ignore_hover))
13963 {
13964
2/2
✓ Branch 0 taken 16429862 times.
✓ Branch 1 taken 36048052 times.
52477914 bool can_diag = (diagonalMovement || get_qr(qr_DISABLE_4WAY_GRIDLOCK));
13965 52477914 int32_t ispitul = getpitfall(x,y+(bigHitbox?0:8));
13966 52477914 int32_t ispitbl = getpitfall(x,y+15);
13967 52477914 int32_t ispitur = getpitfall(x+15,y+(bigHitbox?0:8));
13968 52477914 int32_t ispitbr = getpitfall(x+15,y+15);
13969 52477914 int32_t ispitul_50 = getpitfall(x+8,y+(bigHitbox?8:12));
13970 52477914 int32_t ispitbl_50 = getpitfall(x+8,y+(bigHitbox?7:11));
13971 52477914 int32_t ispitur_50 = getpitfall(x+7,y+(bigHitbox?8:12));
13972 52477914 int32_t ispitbr_50 = getpitfall(x+7,y+(bigHitbox?7:11));
13973 52477914 int32_t ispitul_75 = getpitfall(x+12,y+(bigHitbox?12:14));
13974 52477914 int32_t ispitbl_75 = getpitfall(x+12,y+(bigHitbox?3:9));
13975 52477914 int32_t ispitur_75 = getpitfall(x+3,y+(bigHitbox?12:14));
13976 52477914 int32_t ispitbr_75 = getpitfall(x+3,y+(bigHitbox?3:9));
13977 static const int32_t flag_pit_irresistable = (1<<24);
13978
5/5
✓ Branch 0 taken 52410901 times.
✓ Branch 1 taken 7722 times.
✓ Branch 2 taken 914 times.
✓ Branch 3 taken 34895 times.
✓ Branch 4 taken 23482 times.
52477914 switch((ispitul?1:0) + (ispitur?1:0) + (ispitbl?1:0) + (ispitbr?1:0))
13979 {
13980 7722 case 4: return -2; //Fully over pit; fall in
13981 case 3:
13982 {
13983
6/6
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 468 times.
✓ Branch 2 taken 276 times.
✓ Branch 3 taken 170 times.
✓ Branch 4 taken 254 times.
✓ Branch 5 taken 22 times.
914 if(ispitul && ispitur && ispitbl) //UL_3
13984 {
13985
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(ispitul_50)
13986 {
13987
3/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13988 6 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13989 }
13990 }
13991
5/6
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 468 times.
✓ Branch 2 taken 254 times.
✓ Branch 3 taken 170 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 254 times.
892 else if(ispitul && ispitur && ispitbr) //UR_3
13992 {
13993
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 215 times.
254 if(ispitur_50)
13994 {
13995
5/6
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
39 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13996 23 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13997 }
13998 215 }
13999
4/6
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 468 times.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 170 times.
638 else if(ispitul && ispitbl && ispitbr) //BL_3
14000 {
14001
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 156 times.
170 if(ispitbl_50)
14002 {
14003
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
14 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
14004 14 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
14005 }
14006 156 }
14007
3/6
✓ Branch 0 taken 468 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 468 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 468 times.
468 else if(ispitbl && ispitur && ispitbr) //BR_3
14008 {
14009
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 464 times.
468 if(ispitbr_50)
14010 {
14011
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
14012 4 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
14013 }
14014 464 }
14015 835 break;
14016 }
14017 case 2:
14018 {
14019
4/4
✓ Branch 0 taken 18228 times.
✓ Branch 1 taken 16667 times.
✓ Branch 2 taken 15791 times.
✓ Branch 3 taken 2437 times.
34895 if(ispitul && ispitur) //Up
14020 {
14021
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 2323 times.
2437 if(DrunkDown())
14022 {
14023
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if(ispitul_75 && ispitur_75) //Straight up
14024 {
14025 return up | flag_pit_irresistable | (ispitul << 8);
14026 }
14027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 else if(ispitul_75)
14028 {
14029 return (can_diag ? l_up : left) | flag_pit_irresistable | (ispitul << 8);
14030 }
14031
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 else if(ispitur_75)
14032 {
14033 return (can_diag ? r_up : right) | flag_pit_irresistable | (ispitur << 8);
14034 }
14035 114 else return -1;
14036 }
14037 else
14038 {
14039
3/4
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 2121 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202 times.
2323 if(ispitul_50 && ispitur_50) //Straight up
14040 {
14041
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 132 times.
202 return up | ((ispitul_75 || ispitur_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
14042 }
14043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2121 times.
2121 else if(ispitul_50)
14044 {
14045 if(DrunkRight() && !ispitul_75) return -1;
14046 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
14047 }
14048
1/2
✓ Branch 0 taken 2121 times.
✗ Branch 1 not taken.
2121 else if(ispitur_50)
14049 {
14050 if(DrunkLeft() && !ispitur_75) return -1;
14051 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
14052 }
14053 }
14054 2121 }
14055
4/4
✓ Branch 0 taken 18742 times.
✓ Branch 1 taken 13716 times.
✓ Branch 2 taken 15775 times.
✓ Branch 3 taken 2967 times.
32458 else if(ispitbl && ispitbr) //Down
14056 {
14057
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 2893 times.
2967 if(DrunkUp())
14058 {
14059
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
74 if(ispitbl_75 && ispitbr_75) //Straight down
14060 {
14061 4 return down | flag_pit_irresistable | (ispitbl << 8);
14062 }
14063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 else if(ispitbl_75)
14064 {
14065 return (can_diag ? l_down : left) | flag_pit_irresistable | (ispitbl << 8);
14066 }
14067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 else if(ispitbr_75)
14068 {
14069 return (can_diag ? r_down : right) | flag_pit_irresistable | (ispitbr << 8);
14070 }
14071 70 else return -1;
14072 }
14073 else
14074 {
14075
3/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 2843 times.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
2893 if(ispitbl_50 && ispitbr_50) //Straight down
14076 {
14077
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 40 times.
50 return down | ((ispitbl_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitbl << 8);
14078 }
14079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2843 times.
2843 else if(ispitbl_50)
14080 {
14081 if(DrunkRight() && !ispitbl_75) return -1;
14082 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
14083 }
14084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2843 times.
2843 else if(ispitbr_50)
14085 {
14086 if(DrunkLeft() && !ispitbr_75) return -1;
14087 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
14088 }
14089 }
14090 2843 }
14091
3/4
✓ Branch 0 taken 15775 times.
✓ Branch 1 taken 13716 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15775 times.
29491 else if(ispitbl && ispitul) //Left
14092 {
14093
2/2
✓ Branch 0 taken 836 times.
✓ Branch 1 taken 14939 times.
15775 if(DrunkRight())
14094 {
14095
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 836 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
836 if(ispitul_75 && ispitbl_75) //Straight left
14096 {
14097 return left | flag_pit_irresistable | (ispitul << 8);
14098 }
14099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836 times.
836 else if(ispitul_75)
14100 {
14101 return (can_diag ? l_up : up) | flag_pit_irresistable | (ispitul << 8);
14102 }
14103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836 times.
836 else if(ispitbl_75)
14104 {
14105 return (can_diag ? l_down : down) | flag_pit_irresistable | (ispitbl << 8);
14106 }
14107 836 else return -1;
14108 }
14109 else
14110 {
14111
3/4
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 14519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 420 times.
14939 if(ispitul_50 && ispitbl_50) //Straight left
14112 {
14113
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 315 times.
420 return left | ((ispitul_75 || ispitbl_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
14114 }
14115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14519 times.
14519 else if(ispitul_50)
14116 {
14117 if(DrunkDown() && !ispitul_75) return -1;
14118 return (can_diag ? l_up : up) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
14119 }
14120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14519 times.
14519 else if(ispitbl_50)
14121 {
14122 if(DrunkUp() && !ispitbl_75) return -1;
14123 return (can_diag ? l_down : down) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
14124 }
14125 }
14126 14519 }
14127
3/4
✓ Branch 0 taken 13716 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 13700 times.
13716 else if(ispitbr && ispitur) //Right
14128 {
14129
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 12904 times.
13700 if(DrunkLeft())
14130 {
14131
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 777 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
796 if(ispitur_75 && ispitbr_75) //Straight right
14132 {
14133 19 return right | flag_pit_irresistable | (ispitur << 8);
14134 }
14135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777 times.
777 else if(ispitur_75)
14136 {
14137 return (can_diag ? r_up : up) | flag_pit_irresistable | (ispitur << 8);
14138 }
14139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777 times.
777 else if(ispitbr_75)
14140 {
14141 return (can_diag ? r_down : down) | flag_pit_irresistable | (ispitbr << 8);
14142 }
14143 777 else return -1;
14144 }
14145 else
14146 {
14147
3/4
✓ Branch 0 taken 530 times.
✓ Branch 1 taken 12374 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 530 times.
12904 if(ispitur_50 && ispitbr_50) //Straight right
14148 {
14149
2/2
✓ Branch 0 taken 368 times.
✓ Branch 1 taken 162 times.
530 return right | ((ispitur_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitur << 8);
14150 }
14151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12374 times.
12374 else if(ispitur_50)
14152 {
14153 if(DrunkDown() && !ispitur_75) return -1;
14154 return (can_diag ? r_up : up) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
14155 }
14156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12374 times.
12374 else if(ispitbr_50)
14157 {
14158 if(DrunkUp() && !ispitbr_75) return -1;
14159 return (can_diag ? r_down : down) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
14160 }
14161 }
14162 12374 }
14163 31873 break;
14164 }
14165 case 1:
14166 {
14167
4/4
✓ Branch 0 taken 7279 times.
✓ Branch 1 taken 16203 times.
✓ Branch 2 taken 7274 times.
✓ Branch 3 taken 5 times.
23482 if(ispitul && ispitul_50) //UL_1
14168 {
14169
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
5 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
14170 5 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
14171 }
14172
4/4
✓ Branch 0 taken 5486 times.
✓ Branch 1 taken 17991 times.
✓ Branch 2 taken 5399 times.
✓ Branch 3 taken 87 times.
23477 if(ispitur && ispitur_50) //UR_1
14173 {
14174
5/6
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 57 times.
✓ Branch 5 taken 14 times.
87 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
14175 14 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
14176 }
14177
4/4
✓ Branch 0 taken 4339 times.
✓ Branch 1 taken 19051 times.
✓ Branch 2 taken 4336 times.
✓ Branch 3 taken 3 times.
23390 if(ispitbl && ispitbl_50) //BL_1
14178 {
14179
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
14180 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
14181 }
14182
4/4
✓ Branch 0 taken 6378 times.
✓ Branch 1 taken 17009 times.
✓ Branch 2 taken 6324 times.
✓ Branch 3 taken 54 times.
23387 if(ispitbr && ispitbr_50) //BR_1
14183 {
14184
5/6
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 5 times.
54 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
14185 5 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
14186 }
14187 23333 break;
14188 }
14189 }
14190 52466942 }
14191 53876091 return -1;
14192 53887063 }
14193
14194 11848311 bool HeroClass::pitslide() //Runs pitslide movement; returns true if pit is irresistable
14195 {
14196 11848311 pitfall();
14197
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 11848293 times.
11848311 if(fallclk) return true;
14198 11848293 int32_t val = check_pitslide();
14199 //Val should not be -2 here; if -2 would have been returned, the 'return true' above should have triggered!
14200
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 11848076 times.
11848293 if(val == -1)
14201 {
14202 11848076 pit_pulldir = -1;
14203 11848076 pit_pullclk = 0;
14204 11848076 return false;
14205 }
14206 217 int32_t dir = val&0xFF;
14207 217 int32_t cmbid = (val&0xFFFF00)>>8;
14208 217 int32_t sensitivity = combobuf[cmbid].attribytes[2];
14209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 if(combobuf[cmbid].usrflags&cflag5) //No pull at all
14210 {
14211 pit_pulldir = -1;
14212 pit_pullclk = 0;
14213 return false;
14214 }
14215
4/6
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 215 times.
✓ Branch 5 taken 2 times.
217 if(dir > -1 && !(hoverflags & HOV_PITFALL_OUT) && try_hover()) //Engage hovers
14216 {
14217 2 pit_pulldir = -1;
14218 2 pit_pullclk = 0;
14219 2 return false;
14220 }
14221 215 pit_pulldir = dir;
14222 215 int32_t step = 1;
14223
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 10 times.
215 if(sensitivity == 0)
14224 {
14225 10 step = 2;
14226 10 sensitivity = 1;
14227 10 }
14228
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 158 times.
215 if(pit_pullclk++ % sensitivity) //No pull this frame
14229 57 return (val&0x100);
14230
4/4
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 166 times.
✓ Branch 3 taken 158 times.
324 for(; step > 0 && !fallclk; --step)
14231 {
14232
3/3
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 41 times.
166 switch(dir)
14233 {
14234 case l_up: case l_down: case left:
14235 52 --x; break;
14236 case r_up: case r_down: case right:
14237 73 ++x; break;
14238 }
14239
3/3
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 117 times.
166 switch(dir)
14240 {
14241 case l_up: case r_up: case up:
14242 37 --y; break;
14243 case l_down: case r_down: case down:
14244 12 ++y; break;
14245 }
14246 166 pitfall();
14247 166 }
14248
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 36 times.
158 return fallclk || (val&0x100);
14249 11848311 }
14250
14251 11852257 void HeroClass::pitfall()
14252 {
14253
2/2
✓ Branch 0 taken 3780 times.
✓ Branch 1 taken 11848477 times.
11852257 if(fallclk)
14254 {
14255 3780 drop_liftwpn();
14256
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 3726 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
3780 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
14257 //Handle falling
14258
2/2
✓ Branch 0 taken 3726 times.
✓ Branch 1 taken 54 times.
3780 if(!--fallclk)
14259 {
14260 54 std::vector<int32_t> &ev = FFCore.eventData;
14261 54 ev.clear();
14262 54 ev.push_back(fallCombo*10000);
14263
14264 54 throwGenScriptEvent(GENSCR_EVENT_PLAYER_FALL);
14265
14266 54 fallCombo = ev[0]/10000;
14267
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
54 if(fallCombo < 0 || fallCombo >= MAXCOMBOS)
14268 fallCombo = 0;
14269
14270 54 int32_t dmg = game->get_hp_per_heart()/4;
14271 54 bool dmg_perc = false;
14272 54 bool warp = false;
14273
14274 54 action=none; FFCore.setHeroAction(none);
14275
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 newcombo* cmb = fallCombo ? &combobuf[fallCombo] : NULL;
14276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(cmb)
14277 {
14278 54 dmg = cmb->attributes[0]/10000L;
14279 54 dmg_perc = cmb->usrflags&cflag3;
14280 54 warp = cmb->usrflags&cflag1;
14281 54 }
14282
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if(cheat_superman && dmg > 0)
14283 dmg = 0;
14284
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 38 times.
54 if(dmg) //Damage
14285 {
14286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(dmg > 0) hclk=48; //IFrames only if damaged, not if healed
14287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 game->set_life(vbound(int32_t(dmg_perc ? game->get_life() - ((vbound(dmg,-100,100)/100.0)*game->get_maxlife()) : (game->get_life()-int64_t(dmg))),0,game->get_maxlife()));
14288 38 }
14289
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 51 times.
54 if(warp) //Warp
14290 {
14291 3 sdir = dir;
14292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(cmb->usrflags&cflag2) //Direct Warp
14293 {
14294 3 didpit=true;
14295 3 pitx=x;
14296 3 pity=y;
14297 3 }
14298 3 dowarp(0,vbound(cmb->attribytes[1],0,3),0);
14299 3 }
14300 else //Reset to screen entry
14301 {
14302 51 go_respawn_point();
14303 }
14304 54 }
14305 3780 }
14306
2/2
✓ Branch 0 taken 379433 times.
✓ Branch 1 taken 11469044 times.
11848477 else if(can_pitfall())
14307 {
14308 11469044 bool ispitul = ispitfall(x,y+(bigHitbox?0:8));
14309 11469044 bool ispitbl = ispitfall(x,y+15);
14310 11469044 bool ispitur = ispitfall(x+15,y+(bigHitbox?0:8));
14311 11469044 bool ispitbr = ispitfall(x+15,y+15);
14312 11469044 int32_t pitctr = getpitfall(x+8,y+(bigHitbox?8:12));
14313
9/10
✓ Branch 0 taken 4586 times.
✓ Branch 1 taken 11464458 times.
✓ Branch 2 taken 2856 times.
✓ Branch 3 taken 1730 times.
✓ Branch 4 taken 57 times.
✓ Branch 5 taken 2799 times.
✓ Branch 6 taken 54 times.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 54 times.
11469044 if(ispitul && ispitbl && ispitur && ispitbr && pitctr)
14314 {
14315
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 if(!(hoverflags & HOV_PITFALL_OUT) && try_hover()) return;
14316
3/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 42 times.
54 if(!bigHitbox && !ispitfall(x,y)) y = (y.getInt() + 8 - (y.getInt() % 8)); //Make the falling sprite fully over the pit
14317 54 fallclk = PITFALL_FALL_FRAMES;
14318 54 fallCombo = pitctr;
14319 54 action=falling; FFCore.setHeroAction(falling);
14320 54 spins = 0;
14321 54 charging = 0;
14322 54 drop_liftwpn();
14323 54 }
14324 11469044 }
14325 11852257 }
14326
14327 void HeroClass::handle_slide(newcombo const& icecmb, zfix& dx, zfix& dy)
14328 {
14329 bool is_inair = z || fakez;
14330 zfix odx = dx, ody = dy;
14331 if(sliding == 2 && !is_inair) //landed from air-sliding
14332 {
14333 if((ice_vx+odx).sign() != ice_vx.sign())
14334 ice_vx = 0;
14335 if((ice_vy+ody).sign() != ice_vy.sign())
14336 ice_vy = 0;
14337 sliding = 1;
14338 }
14339 if(!sliding) //just hit the ice
14340 {
14341 if(is_inair)
14342 return;
14343 sliding = 1;
14344 zfix start_perc = icecmb.attribytes[0] / 100_zf;
14345 ice_vx = dx * start_perc;
14346 ice_vy = dy * start_perc;
14347 ice_entry_count = ice_entry_mcount = icecmb.attribytes[1];
14348 }
14349 else //not the first frame sliding
14350 {
14351 if(is_inair)
14352 sliding = 2;
14353 zfix accel = zslongToFix(zc_max(1,icecmb.attributes[0]));
14354 zfix decel = zslongToFix(zc_max(1,icecmb.attributes[1]));
14355
14356 if(ice_entry_count)
14357 {
14358 if(--ice_entry_count)
14359 {
14360 zfix perc = zfix(ice_entry_count)/ice_entry_mcount;
14361 perc *= perc; //square the portion, for a better transition
14362 zfix normal_rate = zfix(steprate)/100/2;
14363 decel = (perc*normal_rate)+((1-perc)*decel);
14364 }
14365 }
14366 //!TODO Traction Boots can be added here, with a multiplier on accel/decel
14367 //Accelerate in the pushed direction
14368 if(is_inair)
14369 {
14370 static const int air_accel = 100;
14371 accel = abs(odx)/air_accel;
14372 if(accel)
14373 {
14374 if(odx < 0)
14375 {
14376 if(ice_vx - accel < odx)
14377 {
14378 if(ice_vx > odx)
14379 ice_vx = odx;
14380 else odx = 0; //allow decel
14381 }
14382 else ice_vx -= accel;
14383 }
14384 else //if(odx > 0)
14385 {
14386 if(ice_vx + accel > odx)
14387 {
14388 if(ice_vx < odx)
14389 ice_vx = odx;
14390 else odx = 0; //allow decel
14391 }
14392 else ice_vx += accel;
14393 }
14394 }
14395 accel = abs(ody)/air_accel;
14396 if(accel)
14397 {
14398 if(ody < 0)
14399 {
14400 if(ice_vy - accel < ody)
14401 {
14402 if(ice_vy > ody)
14403 ice_vy = ody;
14404 else ody = 0; //allow decel
14405 }
14406 else ice_vy -= accel;
14407 }
14408 else //if(ody > 0)
14409 {
14410 if(ice_vy + accel > ody)
14411 {
14412 if(ice_vy < ody)
14413 ice_vy = ody;
14414 else ody = 0; //allow decel
14415 }
14416 else ice_vy += accel;
14417 }
14418 }
14419 }
14420 else if(accel)
14421 {
14422 if(odx > 0)
14423 ice_vx += accel;
14424 else if(odx < 0)
14425 ice_vx -= accel;
14426 if(ody > 0)
14427 ice_vy += accel;
14428 else if(ody < 0)
14429 ice_vy -= accel;
14430 }
14431 //Decelerate in non-pushed direction
14432 if(is_inair)
14433 decel = zinit.air_drag;
14434 if(decel)
14435 {
14436 if(ice_vx)
14437 {
14438 if(!odx && abs(ice_vx) < decel)
14439 ice_vx = 0;
14440 else if(ice_vx > 0 && odx <= 0)
14441 ice_vx -= decel;
14442 else if(ice_vx < 0 && odx >= 0)
14443 ice_vx += decel;
14444 }
14445 if(ice_vy)
14446 {
14447 if(!ody && abs(ice_vy) < decel)
14448 ice_vy = 0;
14449 else if(ice_vy > 0 && ody <= 0)
14450 ice_vy -= decel;
14451 else if(ice_vy < 0 && ody >= 0)
14452 ice_vy += decel;
14453 }
14454 }
14455 }
14456 zfix cap = zslongToFix(zc_max(1,abs(icecmb.attributes[2])));
14457 dx = ice_vx = vbound(ice_vx, -cap, cap);
14458 dy = ice_vy = vbound(ice_vy, -cap, cap);
14459 if(!dx && !dy)
14460 ice_entry_count = 0;
14461 }
14462 250467 void HeroClass::mod_steps(std::vector<zfix*>& v)
14463 {
14464
2/4
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 250467 times.
✗ Branch 3 not taken.
250467 bool can_combo = ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS);
14465
4/6
✓ Branch 0 taken 21068 times.
✓ Branch 1 taken 229399 times.
✓ Branch 2 taken 21068 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21068 times.
✗ Branch 5 not taken.
479866 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1) && can_combo) ||
14466
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 229399 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
229399 (isSideViewHero() && (on_sideview_solid_oldpos(this)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1));
14467 //!DIMITODO: add QR for slow combos under hero
14468
4/4
✓ Branch 0 taken 229399 times.
✓ Branch 1 taken 21068 times.
✓ Branch 2 taken 21068 times.
✓ Branch 3 taken 42136 times.
292603 if(slowcombo) for (int32_t i = 0; i <= 1; ++i)
14469 {
14470
2/2
✓ Branch 0 taken 956 times.
✓ Branch 1 taken 41180 times.
42136 if(tmpscr2[i].valid!=0)
14471 {
14472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41180 times.
41180 if (get_qr(qr_OLD_BRIDGE_COMBOS))
14473 {
14474 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i])))
14475 {
14476 slowcombo = false;
14477 break;
14478 }
14479 }
14480 else
14481 {
14482
2/4
✓ Branch 0 taken 41180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41180 times.
✗ Branch 3 not taken.
41180 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i])))
14483 {
14484 slowcombo = false;
14485 break;
14486 }
14487 }
14488 41180 }
14489 63204 }
14490
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & item_flag10);
14491 250467 bool is_swimming = (action == swimming);
14492 250467 int32_t shieldid = getCurrentActiveShield();
14493
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 if(shieldid > -1)
14494 {
14495 itemdata const& shield = itemsbuf[shieldid];
14496 if(shield.flags & item_flag10) //Change Speed flag
14497 {
14498 zfix perc = shield.misc7;
14499 perc /= 100;
14500 if(perc < 0)
14501 perc = (perc*-1)+1;
14502 zfix add(shield.misc8);
14503 add /= 100;
14504 for(zfix* stp : v)
14505 {
14506 zfix& pix = *stp;
14507 pix = (pix * perc) + add;
14508 }
14509 }
14510 }
14511
14512 250467 auto slow_cpos = COMBOPOS(x+7,y+8);
14513
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 250467 times.
✓ Branch 2 taken 250256 times.
✓ Branch 3 taken 1753058 times.
2003314 if(can_combo) for(int q = 6; q >= 0; --q)
14514 {
14515 1753058 mapscr* m = FFCore.tempScreens[q];
14516
2/2
✓ Branch 0 taken 851124 times.
✓ Branch 1 taken 901934 times.
1753058 if(!m->valid) continue;
14517 851124 newcombo const& cmb = combobuf[m->data[slow_cpos]];
14518
14519
2/6
✓ Branch 0 taken 851124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 851124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
851124 if (cmb.speed_mult != 1 || cmb.speed_div || cmb.speed_add)
14520 {
14521
2/2
✓ Branch 0 taken 4255620 times.
✓ Branch 1 taken 851124 times.
5106744 for(zfix* stp : v)
14522 {
14523 4255620 zfix& pix = *stp;
14524 4255620 pix *= cmb.speed_mult;
14525
1/2
✓ Branch 0 taken 4255620 times.
✗ Branch 1 not taken.
4255620 if(cmb.speed_div)
14526 4255620 pix /= cmb.speed_div;
14527 4255620 pix += cmb.speed_add;
14528 }
14529 851124 }
14530
4/4
✓ Branch 0 taken 600868 times.
✓ Branch 1 taken 250256 times.
✓ Branch 2 taken 600657 times.
✓ Branch 3 taken 211 times.
851124 if(q > 0 && cmb.type == cBRIDGE)
14531 {
14532
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 211 times.
211 if(get_qr(qr_OLD_BRIDGE_COMBOS)
14533 ? !_walkflag_layer(x+7,y+8,1,&(tmpscr2[q-1]))
14534 211 : _effectflag_layer(x+7,y+8,1,&(tmpscr2[q-1])))
14535 {
14536 211 break; //Bridge blocks speed change from below it
14537 }
14538 }
14539 1101380 }
14540 250467 zfix mult = 1, div = 1;
14541
2/2
✓ Branch 0 taken 6290 times.
✓ Branch 1 taken 244177 times.
250467 if(is_swimming)
14542 {
14543 6290 mult = game->swim_mult;
14544 6290 div = game->swim_div;
14545 6290 }
14546
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 244177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
244177 else if(slowcharging && slowcombo) //1/2 speed
14547 {
14548 div = 2;
14549 }
14550
3/4
✓ Branch 0 taken 244177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21068 times.
✓ Branch 3 taken 223109 times.
244177 else if(slowcharging || slowcombo) //2/3 speed
14551 {
14552 21068 mult = 2;
14553 21068 div = 3;
14554 21068 }
14555
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 if(!div) div = 1;
14556
3/4
✓ Branch 0 taken 223109 times.
✓ Branch 1 taken 27358 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 223109 times.
250467 if(mult != 1 || div != 1)
14557 {
14558
2/2
✓ Branch 0 taken 136790 times.
✓ Branch 1 taken 27358 times.
164148 for(zfix* stp : v)
14559 {
14560 136790 zfix& pix = *stp;
14561 136790 pix = ((pix / div) * mult);
14562 }
14563 27358 }
14564 250467 }
14565
14566 13191229 void HeroClass::moveheroOld()
14567 {
14568
4/4
✓ Branch 0 taken 13169442 times.
✓ Branch 1 taken 21787 times.
✓ Branch 2 taken 21532 times.
✓ Branch 3 taken 13190014 times.
13191229 if(lstunclock || is_conveyor_stunned) return;
14569 13190014 int32_t xoff=x.getInt()&7;
14570 13190014 int32_t yoff=y.getInt()&7;
14571
4/4
✓ Branch 0 taken 13018496 times.
✓ Branch 1 taken 171518 times.
✓ Branch 2 taken 26622 times.
✓ Branch 3 taken 13045118 times.
13190014 if(NO_GRIDLOCK)
14572 {
14573 198140 xoff = 0;
14574 198140 yoff = 0;
14575 198140 }
14576 13196064 int32_t push=pushing;
14577 13196064 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
14578 13196064 pushing=0;
14579 13196064 zfix temp_step(hero_newstep);
14580 13196064 zfix temp_x(x);
14581 13196064 zfix temp_y(y);
14582
14583 13196064 int32_t flippers_id = current_item_id(itype_flippers);
14584 13196064 itemdata const& itm = itemsbuf[flippers_id];
14585 13196064 byte intbtn = byte(itm.misc3&0xFF);
14586 13196064 bool dive_pressed = getIntBtnInput(intbtn, true, true, false, false, true);
14587 13196064 bool eatdive = false;
14588
2/2
✓ Branch 0 taken 40956 times.
✓ Branch 1 taken 13155108 times.
13196064 if(diveclk>0)
14589 {
14590
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40956 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40956 if (isSideViewHero() && get_qr(qr_SIDESWIM)) diveclk = 0;
14591 40956 --diveclk;
14592
4/8
✓ Branch 0 taken 9502 times.
✓ Branch 1 taken 31454 times.
✓ Branch 2 taken 9502 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9502 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
40956 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag2 && dive_pressed) //Cancellable Diving -V
14593 {
14594 diveclk = itemsbuf[flippers_id].misc2;
14595 eatdive = true;
14596 }
14597 40956 }
14598
4/4
✓ Branch 0 taken 113504 times.
✓ Branch 1 taken 13041604 times.
✓ Branch 2 taken 113277 times.
✓ Branch 3 taken 227 times.
13155108 else if(action == swimming && dive_pressed)
14599 {
14600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227 times.
227 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag1);
14601 227 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
14602
14603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227 times.
227 if(global_diving==screen_diving)
14604 {
14605
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
14606 227 eatdive = true;
14607 227 }
14608 227 }
14609
2/2
✓ Branch 0 taken 13195837 times.
✓ Branch 1 taken 227 times.
13196064 if(eatdive)
14610 227 getIntBtnInput(intbtn, true, true, false, false, false);
14611
14612
2/2
✓ Branch 0 taken 13082914 times.
✓ Branch 1 taken 113150 times.
13196064 if(action==rafting)
14613 {
14614 113150 do_rafting();
14615
14616
2/2
✓ Branch 0 taken 112795 times.
✓ Branch 1 taken 355 times.
113150 if(action==rafting)
14617 {
14618 112795 return;
14619 }
14620
14621
14622 355 set_respawn_point();
14623 355 trySideviewLadder();
14624 355 }
14625
14626 13083269 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
14627 13083269 int32_t btnwpn = -1;
14628
14629 //&0xFFF removes the "bow & arrows" bitmask
14630 //The Quick Sword is allowed to interrupt attacks.
14631
4/4
✓ Branch 0 taken 12905137 times.
✓ Branch 1 taken 178132 times.
✓ Branch 2 taken 8711477 times.
✓ Branch 3 taken 4193660 times.
13083269 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
14632
8/8
✓ Branch 0 taken 11455397 times.
✓ Branch 1 taken 1627872 times.
✓ Branch 2 taken 11444099 times.
✓ Branch 3 taken 11298 times.
✓ Branch 4 taken 390049 times.
✓ Branch 5 taken 1249121 times.
✓ Branch 6 taken 72183 times.
✓ Branch 7 taken 1566987 times.
13083269 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & item_flag5)))
14633 {
14634
2/2
✓ Branch 0 taken 28961 times.
✓ Branch 1 taken 11487321 times.
11516282 if(DrunkrBbtn())
14635 {
14636 28961 btnwpn=getItemFamily(itemsbuf,Bwpn);
14637
2/2
✓ Branch 0 taken 28752 times.
✓ Branch 1 taken 209 times.
28961 dowpn = NEG_OR_MASK(Bwpn,0xFFF);
14638 28961 directWpn = directItemB;
14639 28961 }
14640
2/2
✓ Branch 0 taken 89318 times.
✓ Branch 1 taken 11398003 times.
11487321 else if(DrunkrAbtn())
14641 {
14642 89318 btnwpn=getItemFamily(itemsbuf,Awpn);
14643
2/2
✓ Branch 0 taken 86643 times.
✓ Branch 1 taken 2675 times.
89318 dowpn = NEG_OR_MASK(Awpn,0xFFF);
14644 89318 directWpn = directItemA;
14645 89318 }
14646
4/4
✓ Branch 0 taken 150132 times.
✓ Branch 1 taken 11247871 times.
✓ Branch 2 taken 150076 times.
✓ Branch 3 taken 56 times.
11398003 else if(get_qr(qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
14647 {
14648 56 btnwpn=getItemFamily(itemsbuf,Xwpn);
14649
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 dowpn = NEG_OR_MASK(Xwpn,0xFFF);
14650 56 directWpn = directItemX;
14651 56 }
14652
4/4
✓ Branch 0 taken 150076 times.
✓ Branch 1 taken 11247871 times.
✓ Branch 2 taken 149953 times.
✓ Branch 3 taken 123 times.
11397947 else if(get_qr(qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
14653 {
14654 123 btnwpn=getItemFamily(itemsbuf,Ywpn);
14655
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 dowpn = NEG_OR_MASK(Ywpn,0xFFF);
14656 123 directWpn = directItemY;
14657 123 }
14658
14659
1/2
✓ Branch 0 taken 11516282 times.
✗ Branch 1 not taken.
11516282 if(directWpn >= MAXITEMS) directWpn = -1;
14660
14661 // The Quick Sword only allows repeated sword or wand swings.
14662
7/8
✓ Branch 0 taken 11444099 times.
✓ Branch 1 taken 72183 times.
✓ Branch 2 taken 72183 times.
✓ Branch 3 taken 11444099 times.
✓ Branch 4 taken 71496 times.
✓ Branch 5 taken 687 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 11444786 times.
11516282 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
14663 71496 btnwpn=-1;
14664 11516282 }
14665
14666
2/2
✓ Branch 0 taken 4343271 times.
✓ Branch 1 taken 8739998 times.
13083269 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
14667
11/12
✓ Branch 0 taken 12247023 times.
✓ Branch 1 taken 836246 times.
✓ Branch 2 taken 11686802 times.
✓ Branch 3 taken 560221 times.
✓ Branch 4 taken 8096797 times.
✓ Branch 5 taken 3590005 times.
✓ Branch 6 taken 8037685 times.
✓ Branch 7 taken 59112 times.
✓ Branch 8 taken 85986 times.
✓ Branch 9 taken 7951699 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 85986 times.
13083269 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
14668 {
14669
2/2
✓ Branch 0 taken 3220 times.
✓ Branch 1 taken 82766 times.
85986 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
14670
5/6
✓ Branch 0 taken 85984 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 85969 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
85986 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & item_flag6)))
14671 {
14672
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 85969 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
85969 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
14673 {
14674 paymagiccost(attackid,true);
14675 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
14676 }
14677 85969 SetAttack();
14678 85969 attack=wSword;
14679
14680 85969 attackclk=0;
14681
2/2
✓ Branch 0 taken 3203 times.
✓ Branch 1 taken 82766 times.
85969 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
14682
14683
7/10
✓ Branch 0 taken 85969 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 524 times.
✓ Branch 3 taken 85445 times.
✓ Branch 4 taken 524 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 517 times.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
85969 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
14684 {
14685
1/2
✓ Branch 0 taken 517 times.
✗ Branch 1 not taken.
517 if(!checkmagiccost(dowpn))
14686 {
14687 item_error();
14688 }
14689 else
14690 {
14691 //clear the item script stack for a new script
14692 517 int i = dowpn;
14693 517 FFCore.reset_script_engine_data(ScriptType::Item, i);
14694 517 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
14695 517 did_scripta=true;
14696 }
14697 517 }
14698 85969 }
14699 else
14700 {
14701 17 item_error();
14702 }
14703 85986 }
14704 else
14705 {
14706 12997283 did_scripta=false;
14707 }
14708
14709
6/10
✓ Branch 0 taken 12929762 times.
✓ Branch 1 taken 153507 times.
✓ Branch 2 taken 12929762 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12929762 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12929762 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 12929762 times.
13083269 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
14710 {
14711
3/4
✓ Branch 0 taken 2288094 times.
✓ Branch 1 taken 10641668 times.
✓ Branch 2 taken 2288094 times.
✗ Branch 3 not taken.
12929762 if(DrunkUp() && canSideviewLadder())
14712 {
14713 setOnSideviewLadder(true);
14714 }
14715
3/4
✓ Branch 0 taken 1980742 times.
✓ Branch 1 taken 10949020 times.
✓ Branch 2 taken 1980742 times.
✗ Branch 3 not taken.
12929762 else if(DrunkDown() && canSideviewLadder(true))
14716 {
14717 y+=1;
14718 old_y += 1;
14719 setOnSideviewLadder(true);
14720 }
14721 12929762 }
14722
14723 13083269 int32_t wx=x;
14724 13083269 int32_t wy=y;
14725
3/6
✓ Branch 0 taken 9007789 times.
✓ Branch 1 taken 4075480 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13083269 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13083269 if((action==none || action==walking) && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
14726 {
14727 if((xoff==0)||diagonalMovement)
14728 {
14729 if(DrunkUp()) dir=up;
14730 if(DrunkDown()) dir=down;
14731 }
14732
14733 if((yoff==0)||diagonalMovement)
14734 {
14735 if(DrunkLeft()) dir=left;
14736 if(DrunkRight()) dir=right;
14737 }
14738 }
14739
14740
5/5
✓ Branch 0 taken 26622 times.
✓ Branch 1 taken 3085252 times.
✓ Branch 2 taken 2642070 times.
✓ Branch 3 taken 3532289 times.
✓ Branch 4 taken 3797036 times.
13083269 switch(dir)
14741 {
14742 case up:
14743 3085252 wy-=16;
14744 3085252 break;
14745
14746 case down:
14747 2642070 wy+=16;
14748 2642070 break;
14749
14750 case left:
14751 3532289 wx-=16;
14752 3532289 break;
14753
14754 case right:
14755 3797036 wx+=16;
14756 3797036 break;
14757 }
14758
14759 13083269 do_lens();
14760
14761 13083269 WalkflagInfo info;
14762
14763 13083269 bool no_jinx = true;
14764
6/8
✓ Branch 0 taken 12247023 times.
✓ Branch 1 taken 783002 times.
✓ Branch 2 taken 28396 times.
✓ Branch 3 taken 12218627 times.
✓ Branch 4 taken 28396 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 28396 times.
13083269 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
14765 {
14766 28396 bool paidmagic = false;
14767
1/2
✓ Branch 0 taken 28396 times.
✗ Branch 1 not taken.
28396 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
14768
6/10
✓ Branch 0 taken 28396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26611 times.
✓ Branch 3 taken 1785 times.
✓ Branch 4 taken 1785 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1785 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1785 times.
28396 if(!liftonly && btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
14769 {
14770
1/2
✓ Branch 0 taken 1785 times.
✗ Branch 1 not taken.
1785 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
14771 1785 no_jinx = checkitem_jinx(attackid);
14772
4/8
✓ Branch 0 taken 1784 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1784 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1784 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1785 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & item_flag6)) || checkmagiccost(attackid)))
14773 {
14774
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1784 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1784 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
14775 paymagiccost(attackid,true);
14776 misc_internal_hero_flags |= LF_PAID_WAND_COST;
14777 }
14778 1784 SetAttack();
14779 1784 attack=wWand;
14780 1784 attackclk=0;
14781 1784 }
14782 else
14783 {
14784 1 item_error();
14785 }
14786 1785 }
14787
5/8
✓ Branch 0 taken 26611 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2255 times.
✓ Branch 3 taken 24356 times.
✓ Branch 4 taken 2255 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2255 times.
28866 else if(!liftonly && (btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
14788
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2255 times.
✓ Branch 2 taken 2255 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2255 times.
2255 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
14789 {
14790 2255 no_jinx = checkitem_jinx(dowpn);
14791
3/6
✓ Branch 0 taken 2255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2255 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2255 times.
2255 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
14792 {
14793 item_error();
14794 }
14795 else
14796 {
14797 2255 paymagiccost(dowpn);
14798 2255 paidmagic = true;
14799 2255 SetAttack();
14800 2255 attack=wHammer;
14801
1/2
✓ Branch 0 taken 2255 times.
✗ Branch 1 not taken.
2255 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
14802 2255 attackclk=0;
14803 }
14804 2255 }
14805
5/8
✓ Branch 0 taken 24356 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1832 times.
✓ Branch 3 taken 22524 times.
✓ Branch 4 taken 1832 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1832 times.
26188 else if(!liftonly && (btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
14806
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1832 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1832 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1832 times.
1832 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
14807 {
14808 //checkbunny handled where magic cost is paid
14809
1/2
✓ Branch 0 taken 1832 times.
✗ Branch 1 not taken.
1832 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
14810 1832 no_jinx = checkitem_jinx(attackid);
14811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1832 times.
1832 if(no_jinx)
14812 {
14813 1832 SetAttack();
14814 1832 attack=wFire;
14815 1832 attackclk=0;
14816 1832 }
14817 1832 }
14818
5/8
✓ Branch 0 taken 22524 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 22520 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
22528 else if(!liftonly && (btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
14819
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
14820 {
14821
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
14822 4 no_jinx = checkitem_jinx(attackid);
14823
3/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & item_flag6)) || checkmagiccost(attackid)))
14824 {
14825
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
14826 paymagiccost(attackid,true);
14827 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
14828 }
14829 4 SetAttack();
14830 4 attack=wCByrna;
14831 4 attackclk=0;
14832 4 }
14833 else
14834 {
14835 item_error();
14836 }
14837 4 }
14838
2/8
✓ Branch 0 taken 22520 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 22520 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
22520 else if(!liftonly && (btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
14839 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
14840 {
14841 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
14842 no_jinx = checkitem_jinx(attackid);
14843 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
14844 {
14845 paymagiccost(attackid);
14846 SetAttack();
14847 attack = wBugNet;
14848 attackclk = 0;
14849 sfx(itemsbuf[attackid].usesound);
14850 }
14851 else
14852 {
14853 item_error();
14854 }
14855 }
14856 else
14857 {
14858
1/2
✓ Branch 0 taken 22520 times.
✗ Branch 1 not taken.
22520 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
14859 22520 no_jinx = checkitem_jinx(itmid);
14860
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 22469 times.
22520 if(no_jinx)
14861 {
14862 22469 paidmagic = startwpn(itmid);
14863
14864
2/2
✓ Branch 0 taken 19414 times.
✓ Branch 1 taken 3055 times.
22469 if(paidmagic)
14865 {
14866
6/10
✓ Branch 0 taken 19394 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 19394 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19394 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 19394 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 19394 times.
19414 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
14867 {
14868 ;
14869 20 }
14870 else
14871 {
14872 19394 SetAttack();
14873 19394 attackclk=0;
14874 19394 attack=none;
14875
14876
2/2
✓ Branch 0 taken 5913 times.
✓ Branch 1 taken 13481 times.
19394 if(btnwpn==itype_brang)
14877 {
14878 13481 attack=wBrang;
14879 13481 }
14880 }
14881 19414 }
14882 else
14883 {
14884 // Weapon not started: directWpn should be reset to prev. value.
14885 3055 directWpn = olddirectwpn;
14886 }
14887 22469 }
14888 }
14889
14890
8/12
✓ Branch 0 taken 28396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28344 times.
✓ Branch 3 taken 52 times.
✓ Branch 4 taken 1211 times.
✓ Branch 5 taken 27133 times.
✓ Branch 6 taken 1145 times.
✓ Branch 7 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1145 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
28396 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
14891 {
14892
3/4
✓ Branch 0 taken 1143 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1145 times.
1145 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
14893 {
14894 item_error();
14895 }
14896 else
14897 {
14898 // Only charge for magic if item's magic cost wasn't already charged
14899 // for the item's main use.
14900
4/4
✓ Branch 0 taken 1143 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 1136 times.
1145 if(!paidmagic && attack!=wWand)
14901 1136 paymagiccost(dowpn);
14902 //clear the item script stack for a new script
14903 1145 int i = dowpn;
14904 1145 FFCore.reset_script_engine_data(ScriptType::Item, i);
14905 1145 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
14906 1145 did_scriptb=true;
14907 }
14908 1145 }
14909
14910
8/12
✓ Branch 0 taken 28344 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 28324 times.
✓ Branch 3 taken 20 times.
✓ Branch 4 taken 28324 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 28324 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28324 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 28324 times.
28396 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
14911 {
14912 20 return;
14913 }
14914
2/2
✓ Branch 0 taken 28324 times.
✓ Branch 1 taken 52 times.
28376 if(!no_jinx)
14915 52 did_scriptb = false;
14916 28376 }
14917 else
14918 {
14919 13001629 did_scriptb=false;
14920 }
14921
14922
6/6
✓ Branch 0 taken 11456063 times.
✓ Branch 1 taken 1573942 times.
✓ Branch 2 taken 11333405 times.
✓ Branch 3 taken 122658 times.
✓ Branch 4 taken 26622 times.
✓ Branch 5 taken 11359067 times.
13030005 if(attackclk || action==attacking || action==sideswimattacking)
14923 {
14924
14925
4/8
✓ Branch 0 taken 122658 times.
✓ Branch 1 taken 1600564 times.
✓ Branch 2 taken 122658 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 122658 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1723222 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
14926 {
14927 if((xoff==0)||diagonalMovement)
14928 {
14929 if(DrunkUp()) dir=up;
14930 if(DrunkDown()) dir=down;
14931 }
14932
14933 if((yoff==0)||diagonalMovement)
14934 {
14935 if(DrunkLeft()) dir=left;
14936 if(DrunkRight()) dir=right;
14937 }
14938 }
14939
14940 1723222 bool attacked = doattack();
14941
14942 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
14943
10/12
✓ Branch 0 taken 1720077 times.
✓ Branch 1 taken 3145 times.
✓ Branch 2 taken 1239266 times.
✓ Branch 3 taken 480811 times.
✓ Branch 4 taken 264928 times.
✓ Branch 5 taken 974338 times.
✓ Branch 6 taken 229279 times.
✓ Branch 7 taken 35649 times.
✓ Branch 8 taken 229279 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 229279 times.
1723222 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
14944 {
14945
4/4
✓ Branch 0 taken 110634 times.
✓ Branch 1 taken 118645 times.
✓ Branch 2 taken 37796 times.
✓ Branch 3 taken 72838 times.
229279 if((xoff==0)||diagonalMovement)
14946 {
14947
2/2
✓ Branch 0 taken 140052 times.
✓ Branch 1 taken 16389 times.
156441 if(DrunkUp()) dir=up;
14948
14949
2/2
✓ Branch 0 taken 137053 times.
✓ Branch 1 taken 19388 times.
156441 if(DrunkDown()) dir=down;
14950 156441 }
14951
14952
4/4
✓ Branch 0 taken 87877 times.
✓ Branch 1 taken 141402 times.
✓ Branch 2 taken 35727 times.
✓ Branch 3 taken 52150 times.
229279 if((yoff==0)||diagonalMovement)
14953 {
14954
2/2
✓ Branch 0 taken 151761 times.
✓ Branch 1 taken 25368 times.
177129 if(DrunkLeft()) dir=left;
14955
14956
2/2
✓ Branch 0 taken 150942 times.
✓ Branch 1 taken 26187 times.
177129 if(DrunkRight()) dir=right;
14957 177129 }
14958 229279 }
14959
14960
9/10
✓ Branch 0 taken 1607618 times.
✓ Branch 1 taken 115604 times.
✓ Branch 2 taken 1566632 times.
✓ Branch 3 taken 40986 times.
✓ Branch 4 taken 1566197 times.
✓ Branch 5 taken 435 times.
✓ Branch 6 taken 1561835 times.
✓ Branch 7 taken 4362 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1561835 times.
1723222 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
14961 {
14962 1561835 return;
14963 }
14964
2/2
✓ Branch 0 taken 45783 times.
✓ Branch 1 taken 115604 times.
161387 else if(!attacked)
14965 {
14966 // Spin attack - change direction
14967
3/4
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 114939 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 665 times.
115604 if(spins>1 && attack != wHammer)
14968 {
14969 665 spins--;
14970
14971
2/2
✓ Branch 0 taken 620 times.
✓ Branch 1 taken 45 times.
665 if(spins%5==0)
14972 {
14973
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
14974 45 sfx(itemsbuf[id].usesound,pan(x.getInt()));
14975 45 }
14976 665 attackclk=1;
14977
14978
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 167 times.
✓ Branch 2 taken 166 times.
✓ Branch 3 taken 166 times.
✓ Branch 4 taken 166 times.
665 switch(dir)
14979 {
14980 case up:
14981 167 dir=left;
14982 167 break;
14983
14984 case right:
14985 166 dir=up;
14986 166 break;
14987
14988 case down:
14989 166 dir=right;
14990 166 break;
14991
14992 case left:
14993 166 dir=down;
14994 166 break;
14995 }
14996
14997 665 return;
14998 }
14999 else
15000 {
15001 114939 spins=0;
15002 }
15003
15004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114939 times.
114939 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
15005 114939 else {action=none; FFCore.setHeroAction(none);}
15006 114939 attackclk=0;
15007 114939 charging=0;
15008 114939 }
15009 160722 }
15010
15011
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 11519723 times.
11519789 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
15012 66 return;
15013
15014
2/2
✓ Branch 0 taken 4329118 times.
✓ Branch 1 taken 7190605 times.
11519723 if(action==walking) //still walking
15015 {
15016
9/10
✓ Branch 0 taken 5282042 times.
✓ Branch 1 taken 1908563 times.
✓ Branch 2 taken 3678050 times.
✓ Branch 3 taken 1603992 times.
✓ Branch 4 taken 1936665 times.
✓ Branch 5 taken 1741385 times.
✓ Branch 6 taken 79756 times.
✓ Branch 7 taken 1856909 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 79756 times.
7190605 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
15017 {
15018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79756 times.
79756 if(attackclk>0) SetAttack();
15019 79756 else {action = none; FFCore.setHeroAction(none);}
15020 79756 hero_count=-1;
15021 79756 return;
15022 }
15023
15024 7110849 autostep=false;
15025
15026
4/6
✓ Branch 0 taken 4948676 times.
✓ Branch 1 taken 2162173 times.
✓ Branch 2 taken 4948676 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4948676 times.
7110849 if(!(diagonalMovement || NO_GRIDLOCK))
15027 {
15028
2/4
✓ Branch 0 taken 4948676 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4948676 times.
4948676 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
15029 {
15030 if(dir==up&&yoff)
15031 {
15032 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
15033 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
15034 execute(info);
15035
15036 if(!info.isUnwalkable())
15037 {
15038 moveOld2(up);
15039 }
15040 else
15041 {
15042 action=none; FFCore.setHeroAction(none);
15043 }
15044
15045 return;
15046 }
15047
15048 if(dir==down&&yoff)
15049 {
15050 info = walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
15051 info = info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7]));
15052 execute(info);
15053
15054 if(!info.isUnwalkable())
15055 {
15056 moveOld2(down);
15057 }
15058 else
15059 {
15060 action=none; FFCore.setHeroAction(none);
15061 }
15062
15063 return;
15064 }
15065
15066 if(dir==left&&xoff)
15067 {
15068 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) || walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
15069 execute(info);
15070
15071 if(!info.isUnwalkable())
15072 {
15073 moveOld2(left);
15074 }
15075 else
15076 {
15077 action=none; FFCore.setHeroAction(none);
15078 }
15079
15080 return;
15081 }
15082
15083 if(dir==right&&xoff)
15084 {
15085 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
15086 execute(info);
15087
15088 if(!info.isUnwalkable())
15089 {
15090 moveOld2(right);
15091 }
15092 else
15093 {
15094 action=none; FFCore.setHeroAction(none);
15095 }
15096
15097 return;
15098 }
15099 }
15100 else
15101 {
15102
4/4
✓ Branch 0 taken 1152419 times.
✓ Branch 1 taken 3796257 times.
✓ Branch 2 taken 188754 times.
✓ Branch 3 taken 963665 times.
4948676 if(dir==up&&yoff)
15103 {
15104 963665 while(true)
15105 {
15106 963667 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
15107 963667 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
15108 963667 execute(info);
15109
15110
2/2
✓ Branch 0 taken 5173 times.
✓ Branch 1 taken 958494 times.
963667 if(!info.isUnwalkable())
15111 {
15112 958494 hero_newstep = temp_step;
15113 958494 x = temp_x;
15114 958494 y = temp_y;
15115 958494 moveOld2(up);
15116 958494 return;
15117 }
15118 //Could not move, try moving less
15119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5173 times.
5173 if(temp_y != int32_t(temp_y))
15120 {
15121 temp_y = floor((double)temp_y);
15122 continue;
15123 }
15124
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5171 times.
5173 else if(temp_step > 1)
15125 {
15126
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(temp_step != int32_t(temp_step)) //floor
15127 2 temp_step = floor((double)temp_step);
15128 else --temp_step;
15129 2 continue;
15130 }
15131 else //Can't move less, stop moving
15132 {
15133 5171 action=none; FFCore.setHeroAction(none);
15134 }
15135 5171 return;
15136 }
15137 }
15138
15139
4/4
✓ Branch 0 taken 945024 times.
✓ Branch 1 taken 3039987 times.
✓ Branch 2 taken 156231 times.
✓ Branch 3 taken 788793 times.
3985011 if(dir==down&&yoff)
15140 {
15141 788793 while(true)
15142 {
15143 788847 info = walkflag(temp_x,temp_y+15+temp_step,2,down);
15144 788847 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
15145 788847 execute(info);
15146
15147
2/2
✓ Branch 0 taken 4455 times.
✓ Branch 1 taken 784392 times.
788847 if(!info.isUnwalkable())
15148 {
15149 784392 hero_newstep = temp_step;
15150 784392 x = temp_x;
15151 784392 y = temp_y;
15152 784392 moveOld2(down);
15153 784392 return;
15154 }
15155 //Could not move, try moving less
15156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4455 times.
4455 if(temp_y != int32_t(temp_y))
15157 {
15158 temp_y = floor((double)temp_y);
15159 continue;
15160 }
15161
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 4401 times.
4455 else if(temp_step > 1)
15162 {
15163
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(temp_step != int32_t(temp_step)) //floor
15164 54 temp_step = floor((double)temp_step);
15165 else --temp_step;
15166 54 continue;
15167 }
15168 else //Can't move less, stop moving
15169 {
15170 4401 action=none; FFCore.setHeroAction(none);
15171 }
15172 4401 return;
15173 }
15174 }
15175
15176
4/4
✓ Branch 0 taken 1387303 times.
✓ Branch 1 taken 1808915 times.
✓ Branch 2 taken 232465 times.
✓ Branch 3 taken 1154838 times.
3196218 if(dir==left&&xoff)
15177 {
15178 1154838 while(true)
15179 {
15180 1154838 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) || walkflag(temp_x-temp_step,temp_y+8,1,left);
15181 1154838 execute(info);
15182
15183
2/2
✓ Branch 0 taken 5165 times.
✓ Branch 1 taken 1149673 times.
1154838 if(!info.isUnwalkable())
15184 {
15185 1149673 hero_newstep = temp_step;
15186 1149673 x = temp_x;
15187 1149673 y = temp_y;
15188 1149673 moveOld2(left);
15189 1149673 return;
15190 }
15191 //Could not move, try moving less
15192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5165 times.
5165 if(temp_x != int32_t(temp_x))
15193 {
15194 temp_x = floor((double)temp_x);
15195 continue;
15196 }
15197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5165 times.
5165 else if(temp_step > 1)
15198 {
15199 if(temp_step != int32_t(temp_step)) //floor
15200 temp_step = floor((double)temp_step);
15201 else --temp_step;
15202 continue;
15203 }
15204 else //Can't move less, stop moving
15205 {
15206 5165 action=none; FFCore.setHeroAction(none);
15207 }
15208 5165 return;
15209 }
15210 }
15211
15212
4/4
✓ Branch 0 taken 1463930 times.
✓ Branch 1 taken 577450 times.
✓ Branch 2 taken 245283 times.
✓ Branch 3 taken 1218647 times.
2041380 if(dir==right&&xoff)
15213 {
15214 1218647 while(true)
15215 {
15216 1218709 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) || walkflag(temp_x+15+temp_step,temp_y+8,1,right);
15217 1218709 execute(info);
15218
15219
2/2
✓ Branch 0 taken 5827 times.
✓ Branch 1 taken 1212882 times.
1218709 if(!info.isUnwalkable())
15220 {
15221 1212882 hero_newstep = temp_step;
15222 1212882 x = temp_x;
15223 1212882 y = temp_y;
15224 1212882 moveOld2(right);
15225 1212882 return;
15226 }
15227 //Could not move, try moving less
15228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5827 times.
5827 if(temp_x != int32_t(temp_x))
15229 {
15230 temp_x = floor((double)temp_x);
15231 continue;
15232 }
15233
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 5765 times.
5827 else if(temp_step > 1)
15234 {
15235
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(temp_step != int32_t(temp_step)) //floor
15236 62 temp_step = floor((double)temp_step);
15237 else --temp_step;
15238 62 continue;
15239 }
15240 else //Can't move less, stop moving
15241 {
15242 5765 action=none; FFCore.setHeroAction(none);
15243 }
15244 5765 return;
15245 }
15246 }
15247 }
15248 822733 }
15249
15250 2984906 } // endif (action==walking)
15251
15252
16/24
✓ Branch 0 taken 7161477 times.
✓ Branch 1 taken 152547 times.
✓ Branch 2 taken 7161477 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7161477 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7161477 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7161477 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7161477 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 7161477 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 7161477 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 7161477 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 7120491 times.
✓ Branch 19 taken 40986 times.
✓ Branch 20 taken 7120056 times.
✓ Branch 21 taken 435 times.
✓ Branch 22 taken 91081 times.
✓ Branch 23 taken 7028975 times.
7314024 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
15253 {
15254 7028975 action=none; FFCore.setHeroAction(none);
15255 7028975 }
15256
15257
2/2
✓ Branch 0 taken 3535957 times.
✓ Branch 1 taken 3778067 times.
7314024 if(diagonalMovement)
15258 {
15259
5/5
✓ Branch 0 taken 1136866 times.
✓ Branch 1 taken 537375 times.
✓ Branch 2 taken 442325 times.
✓ Branch 3 taken 679420 times.
✓ Branch 4 taken 739971 times.
3535957 switch(holddir)
15260 {
15261 case up:
15262
2/2
✓ Branch 0 taken 520669 times.
✓ Branch 1 taken 16706 times.
537375 if(!Up())
15263 {
15264 16706 holddir=-1;
15265 16706 }
15266
15267 537375 break;
15268
15269 case down:
15270
2/2
✓ Branch 0 taken 427462 times.
✓ Branch 1 taken 14863 times.
442325 if(!Down())
15271 {
15272 14863 holddir=-1;
15273 14863 }
15274
15275 442325 break;
15276
15277 case left:
15278
2/2
✓ Branch 0 taken 659586 times.
✓ Branch 1 taken 19834 times.
679420 if(!Left())
15279 {
15280 19834 holddir=-1;
15281 19834 }
15282
15283 679420 break;
15284
15285 case right:
15286
2/2
✓ Branch 0 taken 719481 times.
✓ Branch 1 taken 20490 times.
739971 if(!Right())
15287 {
15288 20490 holddir=-1;
15289 20490 }
15290
15291 739971 break;
15292
15293 default:
15294 1136866 break;
15295 } //end switch
15296
15297
4/4
✓ Branch 0 taken 2986357 times.
✓ Branch 1 taken 549600 times.
✓ Branch 2 taken 31652 times.
✓ Branch 3 taken 3017049 times.
3535957 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim()) //!DIRECTION SET
15298 {
15299 581252 walkable = false;
15300
6/6
✓ Branch 0 taken 95415 times.
✓ Branch 1 taken 428523 times.
✓ Branch 2 taken 92341 times.
✓ Branch 3 taken 3074 times.
✓ Branch 4 taken 23327 times.
✓ Branch 5 taken 69014 times.
581252 if(DrunkUp()&&(holddir==-1||holddir==up))
15301 {
15302
5/8
✓ Branch 0 taken 3090 times.
✓ Branch 1 taken 68998 times.
✓ Branch 2 taken 3057 times.
✓ Branch 3 taken 33 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3090 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
72088 if(isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam)
15303 {
15304 }
15305 else
15306 {
15307
5/10
✓ Branch 0 taken 71124 times.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 71124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 71124 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 71124 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
72088 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
15308 {
15309 71124 dir=up;
15310 71124 }
15311
15312 72088 holddir=up;
15313
15314
4/4
✓ Branch 0 taken 9323 times.
✓ Branch 1 taken 62765 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 9321 times.
72088 if(DrunkRight()&&shiftdir!=left)
15315 {
15316 9321 shiftdir=right;
15317
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9321 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9321 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
15318
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9321 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9321 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
15319 9321 }
15320
4/4
✓ Branch 0 taken 8767 times.
✓ Branch 1 taken 54000 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8757 times.
62767 else if(DrunkLeft()&&shiftdir!=right)
15321 {
15322 8757 shiftdir=left;
15323
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8757 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8757 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
15324
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8757 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8757 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
15325 8757 }
15326 else
15327 {
15328 54010 shiftdir=-1;
15329 }
15330
15331 //walkable if Ladder can be placed or is already placed vertically
15332
1/18
✗ Branch 0 not taken.
✓ Branch 1 taken 72088 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
72088 if(isSideViewHero() && !toogam && !((can_deploy_ladder() && get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW)) || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15333 {
15334 walkable=false;
15335 }
15336 else
15337 {
15338
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 72088 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 72084 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
72088 if ((get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW) && can_deploy_ladder()) || (ladderx && laddery && ladderdir==up)) justmoved = 2; //Prevent the slope-snap code from running
15339 72088 do
15340 {
15341 83739 zfix ty = y - hero_newstep;
15342 167478 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
15343 83739 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
15344
15345
3/4
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 83449 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 290 times.
83739 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15346 {
15347 290 info = info || walkflag(x, 0_zf, 2, up);
15348 290 info = info || walkflag(x+15, 0_zf, 1, up);
15349 290 }
15350 83739 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
15351
15352 83739 execute(info);
15353
15354
2/2
✓ Branch 0 taken 22302 times.
✓ Branch 1 taken 61437 times.
83739 if(info.isUnwalkable())
15355 {
15356
2/2
✓ Branch 0 taken 1000 times.
✓ Branch 1 taken 21302 times.
22302 if(y != y.getInt())
15357 {
15358 1000 y.doRound();
15359 1000 }
15360
2/2
✓ Branch 0 taken 10651 times.
✓ Branch 1 taken 10651 times.
21302 else if(hero_newstep > 1)
15361 {
15362
1/2
✓ Branch 0 taken 10651 times.
✗ Branch 1 not taken.
10651 if(hero_newstep != int32_t(hero_newstep)) //floor
15363 10651 hero_newstep = floor((double)hero_newstep);
15364 else --hero_newstep;
15365 10651 }
15366 else
15367 10651 break;
15368 11651 }
15369 61437 else walkable = true;
15370
2/2
✓ Branch 0 taken 11651 times.
✓ Branch 1 taken 61437 times.
73088 }
15371 73088 while(!walkable);
15372 }
15373
15374 72088 int32_t s=shiftdir;
15375
15376
5/6
✓ Branch 0 taken 3090 times.
✓ Branch 1 taken 68998 times.
✓ Branch 2 taken 3058 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 3090 times.
✗ Branch 5 not taken.
72088 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM))
15377 {
15378 shiftdir=-1;
15379 }
15380 else
15381 {
15382
2/2
✓ Branch 0 taken 8757 times.
✓ Branch 1 taken 63331 times.
72088 if(s==left)
15383 {
15384 8757 do
15385 {
15386 10187 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
15387
15388 10187 execute(info);
15389
15390
2/2
✓ Branch 0 taken 2733 times.
✓ Branch 1 taken 7454 times.
10187 if(info.isUnwalkable())
15391 {
15392
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 2606 times.
2733 if(x != x.getInt())
15393 {
15394 127 x.doRound();
15395 127 }
15396
2/2
✓ Branch 0 taken 1303 times.
✓ Branch 1 taken 1303 times.
2606 else if(hero_newstep_diag > 1)
15397 {
15398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
1303 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15399 1303 hero_newstep_diag.doFloor();
15400 else --hero_newstep_diag;
15401 1303 }
15402 else
15403 1303 shiftdir = -1;
15404 2733 }
15405
2/2
✓ Branch 0 taken 6121 times.
✓ Branch 1 taken 1333 times.
7454 else if(walkable)
15406 {
15407 6121 do
15408 {
15409 6151 info = walkflag(x-hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,left);
15410 6151 execute(info);
15411
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 6103 times.
6151 if(info.isUnwalkable())
15412 {
15413
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
48 if(x != x.getInt())
15414 {
15415 12 x.doRound();
15416 12 }
15417
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 18 times.
36 else if(hero_newstep_diag > 1)
15418 {
15419
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15420 18 hero_newstep_diag.doFloor();
15421 else --hero_newstep_diag;
15422 18 }
15423 else
15424 18 shiftdir = -1;
15425 48 }
15426 6103 else break;
15427
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 18 times.
48 }
15428 48 while(shiftdir != -1);
15429 6121 break;
15430 }
15431 1333 else break;
15432
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 1303 times.
2733 }
15433 2733 while(shiftdir != -1);
15434 8757 }
15435
2/2
✓ Branch 0 taken 54010 times.
✓ Branch 1 taken 9321 times.
63331 else if(s==right)
15436 {
15437 9321 do
15438 {
15439 10902 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
15440
15441 10902 execute(info);
15442
15443
2/2
✓ Branch 0 taken 3016 times.
✓ Branch 1 taken 7886 times.
10902 if(info.isUnwalkable())
15444 {
15445
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 2892 times.
3016 if(x != x.getInt())
15446 {
15447 124 x.doRound();
15448 124 }
15449
2/2
✓ Branch 0 taken 1457 times.
✓ Branch 1 taken 1435 times.
2892 else if(hero_newstep_diag > 1)
15450 {
15451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1457 times.
1457 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15452 1457 hero_newstep_diag.doFloor();
15453 else --hero_newstep_diag;
15454 1457 }
15455 else
15456 1435 shiftdir = -1;
15457 3016 }
15458
2/2
✓ Branch 0 taken 6588 times.
✓ Branch 1 taken 1298 times.
7886 else if(walkable)
15459 {
15460 6588 do
15461 {
15462 6610 info = walkflag(x+15+hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,right);
15463 6610 execute(info);
15464
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 6574 times.
6610 if(info.isUnwalkable())
15465 {
15466
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 29 times.
36 if(x != x.getInt())
15467 {
15468 7 x.doRound();
15469 7 }
15470
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 14 times.
29 else if(hero_newstep_diag > 1)
15471 {
15472
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15473 15 hero_newstep_diag.doFloor();
15474 else --hero_newstep_diag;
15475 15 }
15476 else
15477 14 shiftdir = -1;
15478 36 }
15479 6574 else break;
15480
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 14 times.
36 }
15481 36 while(shiftdir != -1);
15482 6588 break;
15483 }
15484 1298 else break;
15485
2/2
✓ Branch 0 taken 1581 times.
✓ Branch 1 taken 1435 times.
3016 }
15486 3016 while(shiftdir != -1);
15487 9321 }
15488 }
15489
15490 72088 moveOld2(up);
15491 72088 shiftdir=s;
15492
15493
2/2
✓ Branch 0 taken 61437 times.
✓ Branch 1 taken 10651 times.
72088 if(!walkable)
15494 {
15495
2/2
✓ Branch 0 taken 3009 times.
✓ Branch 1 taken 7642 times.
10651 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15496 {
15497 7642 x = x.getInt();
15498 7642 y = y.getInt();
15499
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7642 times.
✓ Branch 4 taken 6058 times.
✓ Branch 5 taken 1584 times.
✓ Branch 6 taken 525 times.
✓ Branch 7 taken 7117 times.
9226 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15500
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1584 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1584 times.
✓ Branch 4 taken 1052 times.
✓ Branch 5 taken 532 times.
1584 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15501
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 532 times.
532 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15502 {
15503
7/12
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 513 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 513 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 513 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 513 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 525 times.
525 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
15504 525 sprite::move((zfix)-1,(zfix)0);
15505 525 }
15506 else
15507 {
15508
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7117 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7117 times.
✓ Branch 4 taken 1059 times.
✓ Branch 5 taken 6058 times.
✓ Branch 6 taken 583 times.
✓ Branch 7 taken 6534 times.
13175 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15509
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6058 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6058 times.
✓ Branch 4 taken 5475 times.
✓ Branch 5 taken 583 times.
6058 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15510
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 583 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 583 times.
583 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15511 {
15512
7/12
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 576 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 576 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 576 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 576 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 583 times.
583 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
15513 583 sprite::move((zfix)1,(zfix)0);
15514 583 }
15515 else
15516 {
15517 6534 pushing=push+1;
15518 }
15519 }
15520 7642 }
15521 else
15522 {
15523 3009 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15524 }
15525 10651 }
15526
15527 72088 return;
15528 }
15529 }
15530
15531
6/6
✓ Branch 0 taken 90059 times.
✓ Branch 1 taken 361791 times.
✓ Branch 2 taken 87053 times.
✓ Branch 3 taken 3006 times.
✓ Branch 4 taken 66542 times.
✓ Branch 5 taken 20511 times.
451850 if(DrunkDown()&&(holddir==-1||holddir==down))
15532 {
15533
4/8
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 66861 times.
✓ Branch 2 taken 2687 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2687 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
69548 if(isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam)
15534 {
15535 }
15536 else
15537 {
15538
5/10
✓ Branch 0 taken 69344 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 69344 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 69344 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 69344 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
69548 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
15539 {
15540 69344 dir=down;
15541 69344 }
15542
15543 69548 holddir=down;
15544
15545
4/4
✓ Branch 0 taken 10006 times.
✓ Branch 1 taken 59542 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10000 times.
69548 if(DrunkRight()&&shiftdir!=left)
15546 {
15547 10000 shiftdir=right;
15548
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 10000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
10000 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
15549
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10000 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
15550 10000 }
15551
4/4
✓ Branch 0 taken 10926 times.
✓ Branch 1 taken 48622 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 10918 times.
59548 else if(DrunkLeft()&&shiftdir!=right)
15552 {
15553 10918 shiftdir=left;
15554
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 10918 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
10918 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
15555
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10918 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10918 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
15556 10918 }
15557 else
15558 {
15559 48630 shiftdir=-1;
15560 }
15561
15562 //bool walkable;
15563
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 69548 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
69548 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15564 {
15565 walkable=false;
15566 }
15567 else
15568 {
15569 69548 do
15570 {
15571 78914 info = walkflag(x,15+(y+hero_newstep),2,down);
15572
15573
2/2
✓ Branch 0 taken 47519 times.
✓ Branch 1 taken 31395 times.
78914 if(x.getFloor() & 7)
15574 47519 info = info || walkflag(x+15,15+(y+hero_newstep),1,down);
15575 else
15576 31395 info = info || walkflagMBlock(x+15, 15+(y+hero_newstep));
15577
15578 78914 execute(info);
15579
15580
2/2
✓ Branch 0 taken 17711 times.
✓ Branch 1 taken 61203 times.
78914 if(info.isUnwalkable())
15581 {
15582
2/2
✓ Branch 0 taken 819 times.
✓ Branch 1 taken 16892 times.
17711 if(y != y.getInt())
15583 {
15584 819 y.doRound();
15585 819 }
15586
2/2
✓ Branch 0 taken 8547 times.
✓ Branch 1 taken 8345 times.
16892 else if(hero_newstep > 1)
15587 {
15588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8547 times.
8547 if(hero_newstep != int32_t(hero_newstep)) //floor
15589 8547 hero_newstep = floor((double)hero_newstep);
15590 else --hero_newstep;
15591 8547 }
15592 else
15593 8345 break;
15594 9366 }
15595 61203 else walkable = true;
15596
2/2
✓ Branch 0 taken 9366 times.
✓ Branch 1 taken 61203 times.
70569 }
15597 70569 while(!walkable);
15598 }
15599
15600 69548 int32_t s=shiftdir;
15601
15602
5/6
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 66861 times.
✓ Branch 2 taken 2685 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2687 times.
✗ Branch 5 not taken.
69548 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM))
15603 {
15604 shiftdir=-1;
15605 }
15606 else
15607 {
15608
2/2
✓ Branch 0 taken 10918 times.
✓ Branch 1 taken 58630 times.
69548 if(s==left)
15609 {
15610 10918 do
15611 {
15612 12477 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
15613
15614 12477 execute(info);
15615
15616
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 9543 times.
12477 if(info.isUnwalkable())
15617 {
15618
2/2
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 2750 times.
2934 if(x != x.getInt())
15619 {
15620 184 x.doRound();
15621 184 }
15622
2/2
✓ Branch 0 taken 1375 times.
✓ Branch 1 taken 1375 times.
2750 else if(hero_newstep_diag > 1)
15623 {
15624
1/2
✓ Branch 0 taken 1375 times.
✗ Branch 1 not taken.
1375 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15625 1375 hero_newstep_diag.doFloor();
15626 else --hero_newstep_diag;
15627 1375 }
15628 else
15629 1375 shiftdir = -1;
15630 2934 }
15631
2/2
✓ Branch 0 taken 7958 times.
✓ Branch 1 taken 1585 times.
9543 else if(walkable)
15632 {
15633 7958 do
15634 {
15635 7998 info = walkflag(x-hero_newstep_diag,15+(y+hero_newstep),1,left);
15636 7998 execute(info);
15637
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 7943 times.
7998 if(info.isUnwalkable())
15638 {
15639
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 30 times.
55 if(x != x.getInt())
15640 {
15641 25 x.doRound();
15642 25 }
15643
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 15 times.
30 else if(hero_newstep_diag > 1)
15644 {
15645
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15646 15 hero_newstep_diag.doFloor();
15647 else --hero_newstep_diag;
15648 15 }
15649 else
15650 15 shiftdir = -1;
15651 55 }
15652 7943 else break;
15653
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 15 times.
55 }
15654 55 while(shiftdir != -1);
15655 7958 break;
15656 }
15657 1585 else break;
15658
2/2
✓ Branch 0 taken 1559 times.
✓ Branch 1 taken 1375 times.
2934 }
15659 2934 while(shiftdir != -1);
15660 10918 }
15661
2/2
✓ Branch 0 taken 48630 times.
✓ Branch 1 taken 10000 times.
58630 else if(s==right)
15662 {
15663 10000 do
15664 {
15665 11347 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
15666
15667 11347 execute(info);
15668
15669
2/2
✓ Branch 0 taken 2598 times.
✓ Branch 1 taken 8749 times.
11347 if(info.isUnwalkable())
15670 {
15671
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 2508 times.
2598 if(x != x.getInt())
15672 {
15673 90 x.doRound();
15674 90 }
15675
2/2
✓ Branch 0 taken 1257 times.
✓ Branch 1 taken 1251 times.
2508 else if(hero_newstep_diag > 1)
15676 {
15677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1257 times.
1257 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15678 1257 hero_newstep_diag.doFloor();
15679 else --hero_newstep_diag;
15680 1257 }
15681 else
15682 1251 shiftdir = -1;
15683 2598 }
15684
2/2
✓ Branch 0 taken 7129 times.
✓ Branch 1 taken 1620 times.
8749 else if(walkable)
15685 {
15686 7129 do
15687 {
15688 7175 info = walkflag(x+15+hero_newstep_diag,15+(y+hero_newstep),1,right);
15689 7175 execute(info);
15690
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 7100 times.
7175 if(info.isUnwalkable())
15691 {
15692
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 58 times.
75 if(x != x.getInt())
15693 {
15694 17 x.doRound();
15695 17 }
15696
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 29 times.
58 else if(hero_newstep_diag > 1)
15697 {
15698
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15699 29 hero_newstep_diag.doFloor();
15700 else --hero_newstep_diag;
15701 29 }
15702 else
15703 29 shiftdir = -1;
15704 75 }
15705 7100 else break;
15706
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 29 times.
75 }
15707 75 while(shiftdir != -1);
15708 7129 break;
15709 }
15710 1620 else break;
15711
2/2
✓ Branch 0 taken 1347 times.
✓ Branch 1 taken 1251 times.
2598 }
15712 2598 while(shiftdir != -1);
15713 10000 }
15714 }
15715
15716 69548 moveOld2(down);
15717 69548 shiftdir=s;
15718
15719
2/2
✓ Branch 0 taken 61203 times.
✓ Branch 1 taken 8345 times.
69548 if(!walkable)
15720 {
15721
2/2
✓ Branch 0 taken 3466 times.
✓ Branch 1 taken 4879 times.
8345 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15722 {
15723 4879 x = x.getInt();
15724 4879 y = y.getInt();
15725
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4879 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4879 times.
✓ Branch 4 taken 3594 times.
✓ Branch 5 taken 1285 times.
✓ Branch 6 taken 520 times.
✓ Branch 7 taken 4359 times.
6164 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15726
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1285 times.
✓ Branch 4 taken 748 times.
✓ Branch 5 taken 537 times.
1285 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15727
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 537 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 537 times.
537 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15728 {
15729
9/12
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 516 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 516 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 512 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 512 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 520 times.
520 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
15730 520 sprite::move((zfix)-1,(zfix)0);
15731 520 }
15732
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4359 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4359 times.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 3594 times.
✓ Branch 6 taken 505 times.
✓ Branch 7 taken 3854 times.
7953 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15733
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3594 times.
✓ Branch 4 taken 3089 times.
✓ Branch 5 taken 505 times.
3594 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15734
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 505 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 505 times.
505 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15735 {
15736
7/12
✓ Branch 0 taken 499 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 499 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 499 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 499 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 499 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 505 times.
505 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
15737 505 sprite::move((zfix)1,(zfix)0);
15738 505 }
15739 else
15740 {
15741 3854 pushing=push+1;
15742 }
15743 4879 }
15744 else
15745 {
15746 3466 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15747 }
15748 8345 }
15749
15750 69548 return;
15751 }
15752 }
15753
15754
6/6
✓ Branch 0 taken 96690 times.
✓ Branch 1 taken 285612 times.
✓ Branch 2 taken 93311 times.
✓ Branch 3 taken 3379 times.
✓ Branch 4 taken 93209 times.
✓ Branch 5 taken 102 times.
382302 if(DrunkLeft()&&(holddir==-1||holddir==left))
15755 {
15756
5/8
✓ Branch 0 taken 2992 times.
✓ Branch 1 taken 93596 times.
✓ Branch 2 taken 2945 times.
✓ Branch 3 taken 47 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2992 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
96588 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam)
15757 {
15758 }
15759 else
15760 {
15761
4/6
✓ Branch 0 taken 96189 times.
✓ Branch 1 taken 399 times.
✓ Branch 2 taken 96189 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 96189 times.
96588 if(charging==0 && spins==0 && action != sideswimattacking)
15762 {
15763 96189 dir=left;
15764 96189 }
15765 96588 sideswimdir = left;
15766
15767 96588 holddir=left;
15768
15769
4/4
✓ Branch 0 taken 11718 times.
✓ Branch 1 taken 84870 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11717 times.
96588 if(DrunkUp()&&shiftdir!=down)
15770 {
15771 11717 shiftdir=up;
15772 11717 }
15773
4/4
✓ Branch 0 taken 10587 times.
✓ Branch 1 taken 74284 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 10584 times.
84871 else if(DrunkDown()&&shiftdir!=up)
15774 {
15775 10584 shiftdir=down;
15776 10584 }
15777 else
15778 {
15779 74287 shiftdir=-1;
15780 }
15781
15782 96588 do
15783 {
15784 106523 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep,y+8,1,left);
15785
15786 106523 info = info || walkflag(x-hero_newstep,y+15,1,left);
15787
15788 106523 execute(info);
15789
15790
2/2
✓ Branch 0 taken 19010 times.
✓ Branch 1 taken 87513 times.
106523 if(info.isUnwalkable())
15791 {
15792
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 18148 times.
19010 if(x != x.getInt())
15793 {
15794 862 x.doRound();
15795 862 }
15796
2/2
✓ Branch 0 taken 9073 times.
✓ Branch 1 taken 9075 times.
18148 else if(hero_newstep > 1)
15797 {
15798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9073 times.
9073 if(hero_newstep != int32_t(hero_newstep)) //floor
15799 9073 hero_newstep = floor((double)hero_newstep);
15800 else --hero_newstep;
15801 9073 }
15802 else
15803 9075 break;
15804 9935 }
15805 87513 else walkable = true;
15806
2/2
✓ Branch 0 taken 9935 times.
✓ Branch 1 taken 87513 times.
97448 }
15807 97448 while(!walkable);
15808
15809 96588 int32_t s=shiftdir;
15810
15811
10/14
✓ Branch 0 taken 2992 times.
✓ Branch 1 taken 93596 times.
✓ Branch 2 taken 2948 times.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 2992 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1341 times.
✓ Branch 7 taken 95247 times.
✓ Branch 8 taken 1341 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1341 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1341 times.
✗ Branch 13 not taken.
96588 if((isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15812 {
15813 1341 shiftdir=-1;
15814 1341 }
15815 else
15816 {
15817
2/2
✓ Branch 0 taken 83530 times.
✓ Branch 1 taken 11717 times.
95247 if(s==up)
15818 {
15819 11717 do
15820 {
15821 13347 zfix ty = y - hero_newstep_diag;
15822 26694 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
15823 13347 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
15824
15825
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13340 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
13347 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15826 {
15827 7 info = info || walkflag(x, 0_zf, 2, up);
15828 7 info = info || walkflag(x+15, 0_zf, 1, up);
15829 7 }
15830 13347 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
15831
15832 13347 execute(info);
15833
15834
2/2
✓ Branch 0 taken 3067 times.
✓ Branch 1 taken 10280 times.
13347 if(info.isUnwalkable())
15835 {
15836
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 2874 times.
3067 if(y != y.getInt())
15837 {
15838 193 y.doRound();
15839 193 }
15840
2/2
✓ Branch 0 taken 1437 times.
✓ Branch 1 taken 1437 times.
2874 else if(hero_newstep_diag > 1)
15841 {
15842
1/2
✓ Branch 0 taken 1437 times.
✗ Branch 1 not taken.
1437 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15843 1437 hero_newstep_diag.doFloor();
15844 else --hero_newstep_diag;
15845 1437 }
15846 else
15847 1437 shiftdir = -1;
15848 3067 }
15849
2/2
✓ Branch 0 taken 8612 times.
✓ Branch 1 taken 1668 times.
10280 else if(walkable)
15850 {
15851 8612 do
15852 {
15853 8671 zfix tx = x-hero_newstep, ty = y-hero_newstep_diag;
15854 8671 info = walkflag(tx,(bigHitbox?0:8)+ty,1,up);
15855
15856
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8664 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
8671 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15857 {
15858 7 info = info || walkflag(tx, 0_zf, 1, up);
15859 7 info = info || walkflag(tx+15, 0_zf, 1, up);
15860 7 }
15861 8671 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
15862
15863 8671 execute(info);
15864
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 8574 times.
8671 if(info.isUnwalkable())
15865 {
15866
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 76 times.
97 if(y != y.getInt())
15867 {
15868 21 y.doRound();
15869 21 }
15870
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 38 times.
76 else if(hero_newstep_diag > 1)
15871 {
15872
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15873 38 hero_newstep_diag.doFloor();
15874 else --hero_newstep_diag;
15875 38 }
15876 else
15877 38 shiftdir = -1;
15878 97 }
15879 8574 else break;
15880
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 38 times.
97 }
15881 97 while(shiftdir != -1);
15882 8612 break;
15883 }
15884 1668 else break;
15885
2/2
✓ Branch 0 taken 1630 times.
✓ Branch 1 taken 1437 times.
3067 }
15886 3067 while(shiftdir != -1);
15887 11717 }
15888
2/2
✓ Branch 0 taken 72946 times.
✓ Branch 1 taken 10584 times.
83530 else if(s==down)
15889 {
15890 10584 do
15891 {
15892 12573 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
15893
15894 12573 execute(info);
15895
15896
2/2
✓ Branch 0 taken 3747 times.
✓ Branch 1 taken 8826 times.
12573 if(info.isUnwalkable())
15897 {
15898
2/2
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 3556 times.
3747 if(y != y.getInt())
15899 {
15900 191 y.doRound();
15901 191 }
15902
2/2
✓ Branch 0 taken 1798 times.
✓ Branch 1 taken 1758 times.
3556 else if(hero_newstep_diag > 1)
15903 {
15904
1/2
✓ Branch 0 taken 1798 times.
✗ Branch 1 not taken.
1798 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15905 1798 hero_newstep_diag.doFloor();
15906 else --hero_newstep_diag;
15907 1798 }
15908 else
15909 1758 shiftdir = -1;
15910 3747 }
15911
2/2
✓ Branch 0 taken 7293 times.
✓ Branch 1 taken 1533 times.
8826 else if(walkable)
15912 {
15913 7293 do
15914 {
15915 7309 info = walkflag(x-hero_newstep,y+15+hero_newstep_diag,1,down);
15916 7309 execute(info);
15917
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7281 times.
7309 if(info.isUnwalkable())
15918 {
15919
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 24 times.
28 if(y != y.getInt())
15920 {
15921 4 y.doRound();
15922 4 }
15923
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 else if(hero_newstep_diag > 1)
15924 {
15925
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15926 12 hero_newstep_diag.doFloor();
15927 else --hero_newstep_diag;
15928 12 }
15929 else
15930 12 shiftdir = -1;
15931 28 }
15932 7281 else break;
15933
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 12 times.
28 }
15934 28 while(shiftdir != -1);
15935 7293 break;
15936 }
15937 1533 else break;
15938
2/2
✓ Branch 0 taken 1989 times.
✓ Branch 1 taken 1758 times.
3747 }
15939 3747 while(shiftdir != -1);
15940 10584 }
15941 }
15942
15943 96588 moveOld2(left);
15944 96588 shiftdir=s;
15945
15946
2/2
✓ Branch 0 taken 87513 times.
✓ Branch 1 taken 9075 times.
96588 if(!walkable)
15947 {
15948
2/2
✓ Branch 0 taken 3522 times.
✓ Branch 1 taken 5553 times.
9075 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15949 {
15950 5553 x = x.getInt();
15951 5553 y = y.getInt();
15952 5553 int32_t v1=bigHitbox?0:8;
15953 5553 int32_t v2=bigHitbox?8:12;
15954
15955
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 5553 times.
✓ Branch 2 taken 5553 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4908 times.
✓ Branch 5 taken 645 times.
✓ Branch 6 taken 130 times.
✓ Branch 7 taken 5423 times.
6198 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15956
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 645 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 645 times.
✓ Branch 4 taken 514 times.
✓ Branch 5 taken 131 times.
645 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15957
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 131 times.
131 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15958 {
15959
9/12
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 123 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 120 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 120 times.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 130 times.
130 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
15960 130 sprite::move((zfix)0,(zfix)-1);
15961 130 }
15962
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 5423 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5423 times.
✓ Branch 4 taken 515 times.
✓ Branch 5 taken 4908 times.
✓ Branch 6 taken 138 times.
✓ Branch 7 taken 5285 times.
10331 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15963
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4908 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4908 times.
✓ Branch 4 taken 4770 times.
✓ Branch 5 taken 138 times.
4908 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15964
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 138 times.
138 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15965 {
15966
7/12
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 137 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 137 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 137 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 137 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 138 times.
138 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
15967 138 sprite::move((zfix)0,(zfix)1);
15968 138 }
15969 else
15970 {
15971 5285 pushing=push+1;
15972 }
15973 5553 }
15974 else
15975 {
15976 3522 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15977
15978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3522 times.
3522 if(action!=swimming)
15979 {
15980 3522 }
15981 }
15982 9075 }
15983
15984 96588 return;
15985 }
15986 }
15987
15988
5/6
✓ Branch 0 taken 99382 times.
✓ Branch 1 taken 186332 times.
✓ Branch 2 taken 95916 times.
✓ Branch 3 taken 3466 times.
✓ Branch 4 taken 95916 times.
✗ Branch 5 not taken.
285714 if(DrunkRight()&&(holddir==-1||holddir==right))
15989 {
15990
5/8
✓ Branch 0 taken 3423 times.
✓ Branch 1 taken 95959 times.
✓ Branch 2 taken 3321 times.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3423 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
99382 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam)
15991 {
15992 }
15993 else
15994 {
15995
4/6
✓ Branch 0 taken 98680 times.
✓ Branch 1 taken 702 times.
✓ Branch 2 taken 98680 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 98680 times.
99382 if(charging==0 && spins==0 && action != sideswimattacking)
15996 {
15997 98680 dir=right;
15998 98680 }
15999 99382 sideswimdir = right;
16000
16001 99382 holddir=right;
16002
16003
4/4
✓ Branch 0 taken 11581 times.
✓ Branch 1 taken 87801 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11580 times.
99382 if(DrunkUp()&&shiftdir!=down)
16004 {
16005 11580 shiftdir=up;
16006 11580 }
16007
4/4
✓ Branch 0 taken 9919 times.
✓ Branch 1 taken 77883 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 9915 times.
87802 else if(DrunkDown()&&shiftdir!=up)
16008 {
16009 9915 shiftdir=down;
16010 9915 }
16011 else
16012 {
16013 77887 shiftdir=-1;
16014 }
16015
16016 99382 do
16017 {
16018 110030 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep,y+8,1,right);;
16019
16020 110030 info = info || walkflag(x+15+hero_newstep,y+15,1,right);
16021
16022 110030 execute(info);
16023
16024
2/2
✓ Branch 0 taken 20331 times.
✓ Branch 1 taken 89699 times.
110030 if(info.isUnwalkable())
16025 {
16026
2/2
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 19562 times.
20331 if(x != x.getInt())
16027 {
16028 769 x.doRound();
16029 769 }
16030
2/2
✓ Branch 0 taken 9879 times.
✓ Branch 1 taken 9683 times.
19562 else if(hero_newstep > 1)
16031 {
16032
1/2
✓ Branch 0 taken 9879 times.
✗ Branch 1 not taken.
9879 if(hero_newstep != int32_t(hero_newstep)) //floor
16033 9879 hero_newstep = floor((double)hero_newstep);
16034 else --hero_newstep;
16035 9879 }
16036 else
16037 9683 break;
16038 10648 }
16039 89699 else walkable = true;
16040
2/2
✓ Branch 0 taken 10648 times.
✓ Branch 1 taken 89699 times.
100347 }
16041 100347 while(!walkable);
16042
16043 99382 int32_t s=shiftdir;
16044
16045
10/14
✓ Branch 0 taken 3423 times.
✓ Branch 1 taken 95959 times.
✓ Branch 2 taken 3373 times.
✓ Branch 3 taken 50 times.
✓ Branch 4 taken 3423 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2340 times.
✓ Branch 7 taken 97042 times.
✓ Branch 8 taken 2340 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2340 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2340 times.
✗ Branch 13 not taken.
99382 if((isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
16046 {
16047 2340 shiftdir=-1;
16048 2340 }
16049 else
16050 {
16051
2/2
✓ Branch 0 taken 85462 times.
✓ Branch 1 taken 11580 times.
97042 if(s==up)
16052 {
16053 11580 do
16054 {
16055 12921 zfix ty = y - hero_newstep_diag;
16056 25842 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
16057 12921 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
16058
16059
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 12913 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
12921 if (ty < 0 && !bigHitbox) //sanity check for up scroll
16060 {
16061 8 info = info || walkflag(x, 0_zf, 2, up);
16062 8 info = info || walkflag(x+15, 0_zf, 1, up);
16063 8 }
16064 12921 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
16065
16066 12921 execute(info);
16067
16068
2/2
✓ Branch 0 taken 2490 times.
✓ Branch 1 taken 10431 times.
12921 if(info.isUnwalkable())
16069 {
16070
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2298 times.
2490 if(y != y.getInt())
16071 {
16072 192 y.doRound();
16073 192 }
16074
2/2
✓ Branch 0 taken 1149 times.
✓ Branch 1 taken 1149 times.
2298 else if(hero_newstep_diag > 1)
16075 {
16076
1/2
✓ Branch 0 taken 1149 times.
✗ Branch 1 not taken.
1149 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
16077 1149 hero_newstep_diag.doFloor();
16078 else --hero_newstep_diag;
16079 1149 }
16080 else
16081 1149 shiftdir = -1;
16082 2490 }
16083
2/2
✓ Branch 0 taken 9125 times.
✓ Branch 1 taken 1306 times.
10431 else if(walkable)
16084 {
16085 9125 do
16086 {
16087 9173 zfix tx = x+hero_newstep, ty = y-hero_newstep_diag;
16088 9173 info = walkflag(tx+15,(bigHitbox?0:8)+ty,1,up);
16089
16090
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9167 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
9173 if (ty < 0 && !bigHitbox) //sanity check for up scroll
16091 {
16092 6 info = info || walkflag(tx, 0_zf, 1, up);
16093 6 info = info || walkflag(tx+15, 0_zf, 1, up);
16094 6 }
16095 9173 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
16096 9173 execute(info);
16097
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 9098 times.
9173 if(info.isUnwalkable())
16098 {
16099
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 54 times.
75 if(y != y.getInt())
16100 {
16101 21 y.doRound();
16102 21 }
16103
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 27 times.
54 else if(hero_newstep_diag > 1)
16104 {
16105
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
16106 27 hero_newstep_diag.doFloor();
16107 else --hero_newstep_diag;
16108 27 }
16109 else
16110 27 shiftdir = -1;
16111 75 }
16112 9098 else break;
16113
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 27 times.
75 }
16114 75 while(shiftdir != -1);
16115 9125 break;
16116 }
16117 1306 else break;
16118
2/2
✓ Branch 0 taken 1341 times.
✓ Branch 1 taken 1149 times.
2490 }
16119 2490 while(shiftdir != -1);
16120 11580 }
16121
2/2
✓ Branch 0 taken 75547 times.
✓ Branch 1 taken 9915 times.
85462 else if(s==down)
16122 {
16123 9915 do
16124 {
16125 11620 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
16126
16127 11620 execute(info);
16128
16129
2/2
✓ Branch 0 taken 3167 times.
✓ Branch 1 taken 8453 times.
11620 if(info.isUnwalkable())
16130 {
16131
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 2966 times.
3167 if(y != y.getInt())
16132 {
16133 201 y.doRound();
16134 201 }
16135
2/2
✓ Branch 0 taken 1504 times.
✓ Branch 1 taken 1462 times.
2966 else if(hero_newstep_diag > 1)
16136 {
16137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1504 times.
1504 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
16138 1504 hero_newstep_diag.doFloor();
16139 else --hero_newstep_diag;
16140 1504 }
16141 else
16142 1462 shiftdir = -1;
16143 3167 }
16144
2/2
✓ Branch 0 taken 7115 times.
✓ Branch 1 taken 1338 times.
8453 else if(walkable)
16145 {
16146 7115 do
16147 {
16148 7148 info = walkflag(x+15+hero_newstep,y+15+hero_newstep_diag,1,down);
16149 7148 execute(info);
16150
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 7094 times.
7148 if(info.isUnwalkable())
16151 {
16152
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 44 times.
54 if(y != y.getInt())
16153 {
16154 10 y.doRound();
16155 10 }
16156
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 21 times.
44 else if(hero_newstep_diag > 1)
16157 {
16158
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
16159 23 hero_newstep_diag.doFloor();
16160 else --hero_newstep_diag;
16161 23 }
16162 else
16163 21 shiftdir = -1;
16164 54 }
16165 7094 else break;
16166
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21 times.
54 }
16167 54 while(shiftdir != -1);
16168 7115 break;
16169 }
16170 1338 else break;
16171
2/2
✓ Branch 0 taken 1705 times.
✓ Branch 1 taken 1462 times.
3167 }
16172 3167 while(shiftdir != -1);
16173 9915 }
16174 }
16175
16176 99382 moveOld2(right);
16177 99382 shiftdir=s;
16178
16179
2/2
✓ Branch 0 taken 89699 times.
✓ Branch 1 taken 9683 times.
99382 if(!walkable)
16180 {
16181
2/2
✓ Branch 0 taken 2869 times.
✓ Branch 1 taken 6814 times.
9683 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16182 {
16183 6814 x = x.getInt();
16184 6814 y = y.getInt();
16185 6814 int32_t v1=bigHitbox?0:8;
16186 6814 int32_t v2=bigHitbox?8:12;
16187
16188
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6814 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6814 times.
✓ Branch 4 taken 5924 times.
✓ Branch 5 taken 890 times.
✓ Branch 6 taken 223 times.
✓ Branch 7 taken 6591 times.
7704 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16189
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 890 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 890 times.
✓ Branch 4 taken 645 times.
✓ Branch 5 taken 245 times.
890 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16190
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 245 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 245 times.
245 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16191 {
16192
7/12
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 216 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 216 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 216 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 216 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 223 times.
223 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
16193 223 sprite::move((zfix)0,(zfix)-1);
16194 223 }
16195
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6591 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6591 times.
✓ Branch 4 taken 667 times.
✓ Branch 5 taken 5924 times.
✓ Branch 6 taken 191 times.
✓ Branch 7 taken 6400 times.
12515 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16196
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5924 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5924 times.
✓ Branch 4 taken 5733 times.
✓ Branch 5 taken 191 times.
5924 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16197
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 191 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 191 times.
191 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16198 {
16199
9/12
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 187 times.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 191 times.
191 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
16200 191 sprite::move((zfix)0,(zfix)1);
16201 191 }
16202 else
16203 {
16204 6400 pushing=push+1;
16205 6400 z3step=2;
16206 }
16207 6814 }
16208 else
16209 {
16210 2869 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16211
16212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2869 times.
2869 if(action!=swimming)
16213 {
16214 2869 }
16215 }
16216 9683 }
16217
16218 99382 return;
16219 }
16220 }
16221 186332 }
16222 else
16223 {
16224
6/6
✓ Branch 0 taken 597562 times.
✓ Branch 1 taken 2419487 times.
✓ Branch 2 taken 583896 times.
✓ Branch 3 taken 13666 times.
✓ Branch 4 taken 127211 times.
✓ Branch 5 taken 456685 times.
3017049 if(DrunkUp()&&(holddir==-1||holddir==up))
16225 {
16226
5/8
✓ Branch 0 taken 3903 times.
✓ Branch 1 taken 466448 times.
✓ Branch 2 taken 3899 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3903 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
470351 if(isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam)
16227 {
16228 }
16229 else
16230 {
16231
3/4
✓ Branch 0 taken 434123 times.
✓ Branch 1 taken 36228 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 434123 times.
470351 if(charging==0 && spins==0)
16232 {
16233 434123 dir=up;
16234 434123 }
16235
16236 470351 holddir=up;
16237
16238
4/4
✓ Branch 0 taken 63518 times.
✓ Branch 1 taken 343433 times.
✓ Branch 2 taken 110 times.
✓ Branch 3 taken 63408 times.
470351 if(DrunkRight()&&shiftdir!=left)
16239 {
16240 63408 shiftdir=right;
16241 63408 }
16242
4/4
✓ Branch 0 taken 52611 times.
✓ Branch 1 taken 290932 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 52531 times.
343543 else if(DrunkLeft()&&shiftdir!=right)
16243 {
16244 52531 shiftdir=left;
16245 52531 }
16246 else
16247 {
16248 291012 shiftdir=-1;
16249 }
16250
16251 //walkable if Ladder can be placed or is already placed vertically
16252
10/18
✓ Branch 0 taken 16485 times.
✓ Branch 1 taken 390466 times.
✓ Branch 2 taken 16485 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 16485 times.
✓ Branch 6 taken 16485 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 16354 times.
✓ Branch 11 taken 16354 times.
✓ Branch 12 taken 16354 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 16354 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 16354 times.
406951 if(isSideViewHero() && !toogam && !(((replay_version_check(0, 23) || get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW)) && can_deploy_ladder()) || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16253 {
16254 16354 walkable=false;
16255 16354 }
16256 else
16257 {
16258
7/8
✓ Branch 0 taken 57465 times.
✓ Branch 1 taken 365840 times.
✓ Branch 2 taken 787 times.
✓ Branch 3 taken 56678 times.
✓ Branch 4 taken 963 times.
✓ Branch 5 taken 421555 times.
✓ Branch 6 taken 963 times.
✗ Branch 7 not taken.
423305 if ((can_deploy_ladder() && get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW)) || (ladderx && laddery && ladderdir==up)) justmoved = 2;
16259 423305 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
16260
16261
2/2
✓ Branch 0 taken 230269 times.
✓ Branch 1 taken 193036 times.
423305 if(x.getInt() & 7)
16262 230269 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
16263 else
16264 193036 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
16265
16266 423305 execute(info);
16267
16268
2/2
✓ Branch 0 taken 66757 times.
✓ Branch 1 taken 356548 times.
423305 if(info.isUnwalkable())
16269 {
16270
2/2
✓ Branch 0 taken 65419 times.
✓ Branch 1 taken 1338 times.
66757 if(z3step==2)
16271 {
16272 65419 z3step=1;
16273 65419 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
16274
16275
2/2
✓ Branch 0 taken 37473 times.
✓ Branch 1 taken 27946 times.
65419 if(x.getInt()&7)
16276 37473 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
16277 else
16278 27946 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
16279
16280 65419 execute(info);
16281
16282
2/2
✓ Branch 0 taken 60321 times.
✓ Branch 1 taken 5098 times.
65419 if(info.isUnwalkable())
16283 {
16284 60321 walkable = false;
16285 60321 }
16286 else
16287 {
16288 5098 walkable=true;
16289 }
16290 65419 }
16291 else
16292 {
16293 1338 walkable=false;
16294 }
16295 66757 }
16296 else
16297 {
16298 356548 walkable = true;
16299 }
16300 }
16301
16302 439659 int32_t s=shiftdir;
16303
16304
5/6
✓ Branch 0 taken 3903 times.
✓ Branch 1 taken 435756 times.
✓ Branch 2 taken 3784 times.
✓ Branch 3 taken 119 times.
✓ Branch 4 taken 3903 times.
✗ Branch 5 not taken.
439659 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM))
16305 {
16306 shiftdir=-1;
16307 }
16308 else
16309 {
16310
2/2
✓ Branch 0 taken 52531 times.
✓ Branch 1 taken 387128 times.
439659 if(s==left)
16311 {
16312 52531 info = (walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left));
16313 52531 execute(info);
16314
16315
2/2
✓ Branch 0 taken 7219 times.
✓ Branch 1 taken 45312 times.
52531 if(info.isUnwalkable())
16316 {
16317 7219 shiftdir=-1;
16318 7219 }
16319
2/2
✓ Branch 0 taken 9326 times.
✓ Branch 1 taken 35986 times.
45312 else if(walkable)
16320 {
16321 35986 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,left);
16322 35986 execute(info);
16323
2/2
✓ Branch 0 taken 35905 times.
✓ Branch 1 taken 81 times.
35986 if(info.isUnwalkable())
16324 {
16325 81 shiftdir=-1;
16326 81 }
16327 35986 }
16328 52531 }
16329
2/2
✓ Branch 0 taken 323720 times.
✓ Branch 1 taken 63408 times.
387128 else if(s==right)
16330 {
16331 63408 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
16332 63408 execute(info);
16333
16334
2/2
✓ Branch 0 taken 9185 times.
✓ Branch 1 taken 54223 times.
63408 if(info.isUnwalkable())
16335 {
16336 9185 shiftdir=-1;
16337 9185 }
16338
2/2
✓ Branch 0 taken 10699 times.
✓ Branch 1 taken 43524 times.
54223 else if(walkable)
16339 {
16340 43524 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,right);
16341 43524 execute(info);
16342
16343
2/2
✓ Branch 0 taken 43438 times.
✓ Branch 1 taken 86 times.
43524 if(info.isUnwalkable())
16344 {
16345 86 shiftdir=-1;
16346 86 }
16347 43524 }
16348 63408 }
16349 }
16350
16351 439659 moveOld2(up);
16352 439659 shiftdir=s;
16353
16354
2/2
✓ Branch 0 taken 361646 times.
✓ Branch 1 taken 78013 times.
439659 if(!walkable)
16355 {
16356
2/2
✓ Branch 0 taken 24276 times.
✓ Branch 1 taken 53737 times.
78013 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16357 {
16358
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 53737 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 53737 times.
✓ Branch 4 taken 29195 times.
✓ Branch 5 taken 24542 times.
✓ Branch 6 taken 2466 times.
✓ Branch 7 taken 51271 times.
78279 if(!_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16359
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24542 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24542 times.
✓ Branch 4 taken 5838 times.
✓ Branch 5 taken 18704 times.
24542 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16360
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18704 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18704 times.
18704 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16361 {
16362
9/12
✓ Branch 0 taken 2397 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 2397 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2397 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2369 times.
✓ Branch 7 taken 28 times.
✓ Branch 8 taken 2369 times.
✓ Branch 9 taken 28 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2466 times.
2466 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
16363 2466 sprite::move((zfix)-1,(zfix)0);
16364 2466 }
16365 else
16366 {
16367
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 51271 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 51271 times.
✓ Branch 4 taken 22076 times.
✓ Branch 5 taken 29195 times.
✓ Branch 6 taken 2457 times.
✓ Branch 7 taken 48814 times.
80466 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16368
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29195 times.
✓ Branch 4 taken 26738 times.
✓ Branch 5 taken 2457 times.
29195 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16369
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2457 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2457 times.
2457 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16370 {
16371
10/12
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 2368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2368 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2355 times.
✓ Branch 7 taken 13 times.
✓ Branch 8 taken 2355 times.
✓ Branch 9 taken 13 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 2455 times.
2457 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
16372 2455 sprite::move((zfix)1,(zfix)0);
16373 2457 }
16374 else
16375 {
16376 48814 pushing=push+1;
16377 }
16378 }
16379
16380 53737 z3step=2;
16381 53737 }
16382 else
16383 {
16384 24276 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16385 24276 z3step=2;
16386 }
16387 78013 }
16388
16389 439659 return;
16390 }
16391 }
16392
16393
6/6
✓ Branch 0 taken 499884 times.
✓ Branch 1 taken 2046814 times.
✓ Branch 2 taken 487995 times.
✓ Branch 3 taken 11889 times.
✓ Branch 4 taken 360920 times.
✓ Branch 5 taken 127075 times.
2546698 if(DrunkDown()&&(holddir==-1||holddir==down))
16394 {
16395
4/8
✓ Branch 0 taken 2675 times.
✓ Branch 1 taken 370134 times.
✓ Branch 2 taken 2675 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2675 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
372809 if(isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam)
16396 {
16397 }
16398 else
16399 {
16400
3/4
✓ Branch 0 taken 367793 times.
✓ Branch 1 taken 5016 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 367793 times.
372809 if(charging==0 && spins==0)
16401 {
16402 367793 dir=down;
16403 367793 }
16404
16405 372809 holddir=down;
16406
16407
4/4
✓ Branch 0 taken 62336 times.
✓ Branch 1 taken 310473 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 62038 times.
372809 if(DrunkRight()&&shiftdir!=left)
16408 {
16409 62038 shiftdir=right;
16410 62038 }
16411
4/4
✓ Branch 0 taken 57786 times.
✓ Branch 1 taken 252985 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 57702 times.
310771 else if(DrunkLeft()&&shiftdir!=right)
16412 {
16413 57702 shiftdir=left;
16414 57702 }
16415 else
16416 {
16417 253069 shiftdir=-1;
16418 }
16419
16420 //bool walkable;
16421
7/12
✓ Branch 0 taken 9145 times.
✓ Branch 1 taken 363664 times.
✓ Branch 2 taken 9145 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9145 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9145 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9145 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 9145 times.
372809 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16422 {
16423 9145 walkable=false;
16424 9145 }
16425 else
16426 {
16427 363664 info = walkflag(x,y+15+z3step,2,down);
16428
16429
2/2
✓ Branch 0 taken 201187 times.
✓ Branch 1 taken 162477 times.
363664 if(x.getInt()&7)
16430 201187 info = info || walkflag(x+16,y+15+z3step,1,down);
16431 else
16432 162477 info = info || walkflagMBlock(x+16, y+15+z3step);
16433
16434 363664 execute(info);
16435
16436
2/2
✓ Branch 0 taken 64733 times.
✓ Branch 1 taken 298931 times.
363664 if(info.isUnwalkable())
16437 {
16438
2/2
✓ Branch 0 taken 63561 times.
✓ Branch 1 taken 1172 times.
64733 if(z3step==2)
16439 {
16440 63561 z3step=1;
16441 63561 info = walkflag(x,y+15+z3step,2,down);
16442
16443
2/2
✓ Branch 0 taken 38657 times.
✓ Branch 1 taken 24904 times.
63561 if(x.getInt()&7)
16444 38657 info = info || walkflag(x+16,y+15+z3step,1,down);
16445 else
16446 24904 info = info || walkflagMBlock(x+16, y+15+z3step);
16447
16448 63561 execute(info);
16449
16450
2/2
✓ Branch 0 taken 59065 times.
✓ Branch 1 taken 4496 times.
63561 if(info.isUnwalkable())
16451 {
16452 59065 walkable = false;
16453 59065 }
16454 else
16455 {
16456 4496 walkable=true;
16457 }
16458 63561 }
16459 else
16460 {
16461 1172 walkable=false;
16462 }
16463 64733 }
16464 else
16465 {
16466 298931 walkable = true;
16467 }
16468 }
16469
16470 372809 int32_t s=shiftdir;
16471
16472
5/6
✓ Branch 0 taken 2675 times.
✓ Branch 1 taken 370134 times.
✓ Branch 2 taken 2670 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 2675 times.
✗ Branch 5 not taken.
372809 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM))
16473 {
16474 shiftdir=-1;
16475 }
16476 else
16477 {
16478
2/2
✓ Branch 0 taken 57702 times.
✓ Branch 1 taken 315107 times.
372809 if(s==left)
16479 {
16480 57702 info = walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left);
16481 57702 execute(info);
16482
16483
2/2
✓ Branch 0 taken 6885 times.
✓ Branch 1 taken 50817 times.
57702 if(info.isUnwalkable())
16484 {
16485 6885 shiftdir=-1;
16486 6885 }
16487
2/2
✓ Branch 0 taken 12264 times.
✓ Branch 1 taken 38553 times.
50817 else if(walkable)
16488 {
16489 38553 info = walkflag(x-1,y+16,1,left);
16490 38553 execute(info);
16491
16492
2/2
✓ Branch 0 taken 38473 times.
✓ Branch 1 taken 80 times.
38553 if(info.isUnwalkable())
16493 {
16494 80 shiftdir=-1;
16495 80 }
16496 38553 }
16497 57702 }
16498
2/2
✓ Branch 0 taken 253069 times.
✓ Branch 1 taken 62038 times.
315107 else if(s==right)
16499 {
16500 62038 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
16501 62038 execute(info);
16502
16503
2/2
✓ Branch 0 taken 9997 times.
✓ Branch 1 taken 52041 times.
62038 if(info.isUnwalkable())
16504 {
16505 9997 shiftdir=-1;
16506 9997 }
16507
2/2
✓ Branch 0 taken 12280 times.
✓ Branch 1 taken 39761 times.
52041 else if(walkable)
16508 {
16509 39761 info = walkflag(x+16,y+16,1,right);
16510 39761 execute(info);
16511
16512
2/2
✓ Branch 0 taken 39675 times.
✓ Branch 1 taken 86 times.
39761 if(info.isUnwalkable())
16513 {
16514 86 shiftdir=-1;
16515 86 }
16516 39761 }
16517 62038 }
16518 }
16519
16520 372809 moveOld2(down);
16521 372809 shiftdir=s;
16522
16523
2/2
✓ Branch 0 taken 303427 times.
✓ Branch 1 taken 69382 times.
372809 if(!walkable)
16524 {
16525
2/2
✓ Branch 0 taken 30578 times.
✓ Branch 1 taken 38804 times.
69382 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16526 {
16527
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 38804 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38804 times.
✓ Branch 4 taken 23792 times.
✓ Branch 5 taken 15012 times.
✓ Branch 6 taken 1959 times.
✓ Branch 7 taken 36845 times.
53816 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16528
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15012 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15012 times.
✓ Branch 4 taken 5754 times.
✓ Branch 5 taken 9258 times.
15012 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16529
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9258 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9258 times.
9258 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16530 {
16531
9/12
✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 1840 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1840 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1832 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 1832 times.
✓ Branch 9 taken 8 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1959 times.
1959 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
16532 1959 sprite::move((zfix)-1,(zfix)0);
16533 1959 }
16534
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 36845 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36845 times.
✓ Branch 4 taken 13053 times.
✓ Branch 5 taken 23792 times.
✓ Branch 6 taken 1790 times.
✓ Branch 7 taken 35055 times.
60637 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16535
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 23792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23792 times.
✓ Branch 4 taken 21980 times.
✓ Branch 5 taken 1812 times.
23792 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16536
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1812 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1812 times.
1812 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16537 {
16538
9/12
✓ Branch 0 taken 1711 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 1711 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1711 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1705 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 1705 times.
✓ Branch 9 taken 6 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1790 times.
1790 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
16539 1790 sprite::move((zfix)1,(zfix)0);
16540 1790 }
16541 else //if(shiftdir==-1)
16542 {
16543 35055 pushing=push+1;
16544
16545
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 34970 times.
35055 if(action!=swimming)
16546 {
16547 34970 }
16548 }
16549
16550 38804 z3step=2;
16551 38804 }
16552 else
16553 {
16554 30578 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16555
16556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30578 times.
30578 if(action!=swimming)
16557 {
16558 30578 }
16559
16560 30578 z3step=2;
16561 }
16562 69382 }
16563
16564 372809 return;
16565 }
16566 }
16567
16568
6/6
✓ Branch 0 taken 584478 times.
✓ Branch 1 taken 1589411 times.
✓ Branch 2 taken 567982 times.
✓ Branch 3 taken 16496 times.
✓ Branch 4 taken 566377 times.
✓ Branch 5 taken 1605 times.
2173889 if(DrunkLeft()&&(holddir==-1||holddir==left))
16569 {
16570
5/8
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 578211 times.
✓ Branch 2 taken 4511 times.
✓ Branch 3 taken 151 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4662 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
582873 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam)
16571 {
16572 }
16573 else
16574 {
16575
3/4
✓ Branch 0 taken 576327 times.
✓ Branch 1 taken 6546 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 576327 times.
582873 if(charging==0 && spins==0)
16576 {
16577 576327 dir=left;
16578 576327 }
16579
16580 582873 holddir=left;
16581
16582
4/4
✓ Branch 0 taken 75537 times.
✓ Branch 1 taken 507336 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 75534 times.
582873 if(DrunkUp()&&shiftdir!=down)
16583 {
16584 75534 shiftdir=up;
16585 75534 }
16586
4/4
✓ Branch 0 taken 60725 times.
✓ Branch 1 taken 446614 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 60713 times.
507339 else if(DrunkDown()&&shiftdir!=up)
16587 {
16588 60713 shiftdir=down;
16589 60713 }
16590 else
16591 {
16592 446626 shiftdir=-1;
16593 }
16594
16595 //bool walkable;
16596 582873 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
16597
16598
2/2
✓ Branch 0 taken 337485 times.
✓ Branch 1 taken 245388 times.
582873 if(y.getInt()&7)
16599 337485 info = info || walkflag(x-z3step,y+16,1,left);
16600
16601 582873 execute(info);
16602
16603
2/2
✓ Branch 0 taken 72078 times.
✓ Branch 1 taken 510795 times.
582873 if(info.isUnwalkable())
16604 {
16605
2/2
✓ Branch 0 taken 70708 times.
✓ Branch 1 taken 1370 times.
72078 if(z3step==2)
16606 {
16607 70708 z3step=1;
16608 70708 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
16609
16610
2/2
✓ Branch 0 taken 27017 times.
✓ Branch 1 taken 43691 times.
70708 if(y.getInt()&7)
16611 43691 info = info || walkflag(x-z3step,y+16,1,left);
16612
16613 70708 execute(info);
16614
16615
2/2
✓ Branch 0 taken 65885 times.
✓ Branch 1 taken 4823 times.
70708 if(info.isUnwalkable())
16616 {
16617 65885 walkable = false;
16618 65885 }
16619 else
16620 {
16621 4823 walkable=true;
16622 }
16623 70708 }
16624 else
16625 {
16626 1370 walkable=false;
16627 }
16628 72078 }
16629 else
16630 {
16631 510795 walkable = true;
16632 }
16633
16634 582873 int32_t s=shiftdir;
16635
16636
10/14
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 578211 times.
✓ Branch 2 taken 4595 times.
✓ Branch 3 taken 67 times.
✓ Branch 4 taken 4662 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 56334 times.
✓ Branch 7 taken 526539 times.
✓ Branch 8 taken 56334 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 56334 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 56334 times.
✗ Branch 13 not taken.
582873 if((isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
16637 {
16638 56334 shiftdir=-1;
16639 56334 }
16640 else
16641 {
16642
2/2
✓ Branch 0 taken 452296 times.
✓ Branch 1 taken 74243 times.
526539 if(s==up)
16643 {
16644 74243 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
16645 74243 execute(info);
16646
16647
2/2
✓ Branch 0 taken 8595 times.
✓ Branch 1 taken 65648 times.
74243 if(info.isUnwalkable())
16648 {
16649 8595 shiftdir=-1;
16650 8595 }
16651
2/2
✓ Branch 0 taken 9976 times.
✓ Branch 1 taken 55672 times.
65648 else if(walkable)
16652 {
16653 55672 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,up);
16654 55672 execute(info);
16655
16656
2/2
✓ Branch 0 taken 55591 times.
✓ Branch 1 taken 81 times.
55672 if(info.isUnwalkable())
16657 {
16658 81 shiftdir=-1;
16659 81 }
16660 55672 }
16661 74243 }
16662
2/2
✓ Branch 0 taken 392144 times.
✓ Branch 1 taken 60152 times.
452296 else if(s==down)
16663 {
16664 60152 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
16665 60152 execute(info);
16666
16667
2/2
✓ Branch 0 taken 9543 times.
✓ Branch 1 taken 50609 times.
60152 if(info.isUnwalkable())
16668 {
16669 9543 shiftdir=-1;
16670 9543 }
16671
2/2
✓ Branch 0 taken 7944 times.
✓ Branch 1 taken 42665 times.
50609 else if(walkable)
16672 {
16673 42665 info = walkflag(x-1,y+16,1,down);
16674 42665 execute(info);
16675
16676
2/2
✓ Branch 0 taken 42594 times.
✓ Branch 1 taken 71 times.
42665 if(info.isUnwalkable())
16677 {
16678 71 shiftdir=-1;
16679 71 }
16680 42665 }
16681 60152 }
16682 }
16683
16684 582873 moveOld2(left);
16685 582873 shiftdir=s;
16686
16687
2/2
✓ Branch 0 taken 515618 times.
✓ Branch 1 taken 67255 times.
582873 if(!walkable)
16688 {
16689
2/2
✓ Branch 0 taken 22472 times.
✓ Branch 1 taken 44783 times.
67255 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16690 {
16691 44783 int32_t v1=bigHitbox?0:8;
16692 44783 int32_t v2=bigHitbox?8:12;
16693
16694
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 44783 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44783 times.
✓ Branch 4 taken 36942 times.
✓ Branch 5 taken 7841 times.
✓ Branch 6 taken 1401 times.
✓ Branch 7 taken 43382 times.
52624 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16695
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7841 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7841 times.
✓ Branch 4 taken 3911 times.
✓ Branch 5 taken 3930 times.
7841 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16696
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3930 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3930 times.
3930 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16697 {
16698
9/12
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 1302 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1302 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1298 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 1298 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1401 times.
1401 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
16699 1401 sprite::move((zfix)0,(zfix)-1);
16700 1401 }
16701
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 43382 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 43382 times.
✓ Branch 4 taken 6440 times.
✓ Branch 5 taken 36942 times.
✓ Branch 6 taken 760 times.
✓ Branch 7 taken 42622 times.
80324 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
16702
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36942 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36942 times.
✓ Branch 4 taken 36182 times.
✓ Branch 5 taken 760 times.
36942 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16703
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16704 {
16705
8/12
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 708 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 708 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 708 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 708 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 759 times.
760 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
16706 759 sprite::move((zfix)0,(zfix)1);
16707 760 }
16708 else //if(shiftdir==-1)
16709 {
16710 42622 pushing=push+1;
16711
16712
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 42417 times.
42622 if(action!=swimming)
16713 {
16714 42417 }
16715 }
16716
16717 44783 z3step=2;
16718 44783 }
16719 else
16720 {
16721 22472 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16722
16723
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 22429 times.
22472 if(action!=swimming)
16724 {
16725 22429 }
16726
16727 22472 z3step=2;
16728 }
16729 67255 }
16730
16731 582873 return;
16732 }
16733 }
16734
16735
5/6
✓ Branch 0 taken 640645 times.
✓ Branch 1 taken 950371 times.
✓ Branch 2 taken 623565 times.
✓ Branch 3 taken 17080 times.
✓ Branch 4 taken 623565 times.
✗ Branch 5 not taken.
1591016 if(DrunkRight()&&(holddir==-1||holddir==right))
16736 {
16737
5/8
✓ Branch 0 taken 4663 times.
✓ Branch 1 taken 635982 times.
✓ Branch 2 taken 4484 times.
✓ Branch 3 taken 179 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4663 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
640645 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam)
16738 {
16739 }
16740 else
16741 {
16742
3/4
✓ Branch 0 taken 632514 times.
✓ Branch 1 taken 8131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 632514 times.
640645 if(charging==0 && spins==0)
16743 {
16744 632514 dir=right;
16745 632514 }
16746
16747 640645 holddir=right;
16748
16749
4/4
✓ Branch 0 taken 82021 times.
✓ Branch 1 taken 558624 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 81990 times.
640645 if(DrunkUp()&&shiftdir!=down)
16750 {
16751 81990 shiftdir=up;
16752 81990 }
16753
4/4
✓ Branch 0 taken 66269 times.
✓ Branch 1 taken 492386 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 66256 times.
558655 else if(DrunkDown()&&shiftdir!=up)
16754 {
16755 66256 shiftdir=down;
16756 66256 }
16757 else
16758 {
16759 492399 shiftdir=-1;
16760 }
16761
16762 //bool walkable;
16763 640645 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
16764
16765
2/2
✓ Branch 0 taken 276495 times.
✓ Branch 1 taken 364150 times.
640645 if(y.getInt()&7)
16766 364150 info = info || walkflag(x+15+z3step,y+16,1,right);
16767
16768 640645 execute(info);
16769
16770
2/2
✓ Branch 0 taken 88326 times.
✓ Branch 1 taken 552319 times.
640645 if(info.isUnwalkable())
16771 {
16772
2/2
✓ Branch 0 taken 86901 times.
✓ Branch 1 taken 1425 times.
88326 if(z3step==2)
16773 {
16774 86901 z3step=1;
16775 86901 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
16776
16777
2/2
✓ Branch 0 taken 33022 times.
✓ Branch 1 taken 53879 times.
86901 if(y.getInt()&7)
16778 53879 info = info || walkflag(x+15+z3step,y+16,1,right);
16779
16780 86901 execute(info);
16781
16782
2/2
✓ Branch 0 taken 79538 times.
✓ Branch 1 taken 7363 times.
86901 if(info.isUnwalkable())
16783 {
16784 79538 walkable = false;
16785 79538 }
16786 else
16787 {
16788 7363 walkable=true;
16789 }
16790 86901 }
16791 else
16792 {
16793 1425 walkable=false;
16794 }
16795 88326 }
16796 else
16797 {
16798 552319 walkable = true;
16799 }
16800
16801 640645 int32_t s=shiftdir;
16802
16803
10/14
✓ Branch 0 taken 4663 times.
✓ Branch 1 taken 635982 times.
✓ Branch 2 taken 4647 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 4663 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 65926 times.
✓ Branch 7 taken 574719 times.
✓ Branch 8 taken 65926 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 65926 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 65926 times.
✗ Branch 13 not taken.
640645 if((isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
16804 {
16805 65926 shiftdir=-1;
16806 65926 }
16807 else
16808 {
16809
2/2
✓ Branch 0 taken 494491 times.
✓ Branch 1 taken 80228 times.
574719 if(s==up)
16810 {
16811 80228 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
16812 80228 execute(info);
16813
16814
2/2
✓ Branch 0 taken 10529 times.
✓ Branch 1 taken 69699 times.
80228 if(info.isUnwalkable())
16815 {
16816 10529 shiftdir=-1;
16817 10529 }
16818
2/2
✓ Branch 0 taken 11746 times.
✓ Branch 1 taken 57953 times.
69699 else if(walkable)
16819 {
16820 57953 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,up);
16821 57953 execute(info);
16822
16823
2/2
✓ Branch 0 taken 57862 times.
✓ Branch 1 taken 91 times.
57953 if(info.isUnwalkable())
16824 {
16825 91 shiftdir=-1;
16826 91 }
16827 57953 }
16828 80228 }
16829
2/2
✓ Branch 0 taken 428712 times.
✓ Branch 1 taken 65779 times.
494491 else if(s==down)
16830 {
16831 65779 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
16832 65779 execute(info);
16833
16834
2/2
✓ Branch 0 taken 11429 times.
✓ Branch 1 taken 54350 times.
65779 if(info.isUnwalkable())
16835 {
16836 11429 shiftdir=-1;
16837 11429 }
16838
2/2
✓ Branch 0 taken 9297 times.
✓ Branch 1 taken 45053 times.
54350 else if(walkable)
16839 {
16840 45053 info = walkflag(x+16,y+16,1,down);
16841 45053 execute(info);
16842
16843
2/2
✓ Branch 0 taken 44973 times.
✓ Branch 1 taken 80 times.
45053 if(info.isUnwalkable())
16844 {
16845 80 shiftdir=-1;
16846 80 }
16847 45053 }
16848 65779 }
16849 }
16850
16851 640645 moveOld2(right);
16852 640645 shiftdir=s;
16853
16854
2/2
✓ Branch 0 taken 559682 times.
✓ Branch 1 taken 80963 times.
640645 if(!walkable)
16855 {
16856
2/2
✓ Branch 0 taken 27206 times.
✓ Branch 1 taken 53757 times.
80963 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16857 {
16858 53757 int32_t v1=bigHitbox?0:8;
16859 53757 int32_t v2=bigHitbox?8:12;
16860
16861 161271 info = !walkflag(x+16,y+v1,1,right)&&
16862 107514 !walkflag(x+16,y+v2,1,right)&&
16863 53757 walkflag(x+16,y+15,1,right);
16864
16865 //do NOT execute these
16866
2/2
✓ Branch 0 taken 1675 times.
✓ Branch 1 taken 52082 times.
53757 if(info.isUnwalkable())
16867 {
16868
10/12
✓ Branch 0 taken 1578 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 1578 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1578 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1577 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1577 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 1674 times.
1675 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
16869 1674 sprite::move((zfix)0,(zfix)-1);
16870 1675 }
16871 else
16872 {
16873 156246 info = walkflag(x+16,y+v1, 1,right)&&
16874 104164 !walkflag(x+16,y+v2-1,1,right)&&
16875 52082 !walkflag(x+16,y+15, 1,right);
16876
16877
2/2
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 51210 times.
52082 if(info.isUnwalkable())
16878 {
16879
7/12
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 832 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 832 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 872 times.
872 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
16880 872 sprite::move((zfix)0,(zfix)1);
16881 872 }
16882 else //if(shiftdir==-1)
16883 {
16884 51210 pushing=push+1;
16885 51210 z3step=2;
16886
16887
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 51144 times.
51210 if(action!=swimming)
16888 {
16889 51144 }
16890 }
16891 }
16892
16893 53757 z3step=2;
16894 53757 }
16895 else
16896 {
16897 27206 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16898
16899
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 27196 times.
27206 if(action!=swimming)
16900 {
16901 27196 }
16902
16903 27206 z3step=2;
16904 }
16905 80963 }
16906
16907 640645 return;
16908 }
16909 }
16910 }
16911
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1136703 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1136703 if(shield_forcedir > -1 && action != rafting)
16912 dir = shield_forcedir;
16913 1136703 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
16914 1136703 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
16915 1136703 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
16916 1136703 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
16917 1136703 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
16918
16919
8/12
✓ Branch 0 taken 151196 times.
✓ Branch 1 taken 985507 times.
✓ Branch 2 taken 151196 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 151196 times.
✓ Branch 6 taken 151196 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 148387 times.
✓ Branch 9 taken 2809 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 148387 times.
1136703 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & item_flag3))&&!(ladderx+laddery)&&z==0&&fakez==0)
16920 {
16921
8/12
✓ Branch 0 taken 571 times.
✓ Branch 1 taken 147816 times.
✓ Branch 2 taken 526 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 479 times.
✓ Branch 5 taken 47 times.
✓ Branch 6 taken 479 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 479 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
148387 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
16922 {
16923 //action=swimming;
16924
3/12
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 360 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
479 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
16925 {
16926 hopclk = 0xFF;
16927 }
16928 479 }
16929 148387 }
16930
16931 1136703 return;
16932 } //endif (LTTPWALK)
16933 3778067 temp_step = hero_newstep;
16934 3778067 temp_x = x;
16935 3778067 temp_y = y;
16936
16937
7/8
✓ Branch 0 taken 2471672 times.
✓ Branch 1 taken 1306395 times.
✓ Branch 2 taken 2420142 times.
✓ Branch 3 taken 51530 times.
✓ Branch 4 taken 59406 times.
✓ Branch 5 taken 2412266 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 59406 times.
3778067 if(isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam)
16938 {
16939
2/4
✓ Branch 0 taken 59406 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 59406 times.
59406 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16940 goto LEFTRIGHT_NEWMOVE;
16941 59406 else goto LEFTRIGHT_OLDMOVE;
16942 }
16943
16944 // make it easier to get in left & right doors
16945
16946 //ignore ladder for this part. sigh sigh sigh -DD
16947 3718661 oldladderx = ladderx;
16948 3718661 oldladdery = laddery;
16949
2/4
✓ Branch 0 taken 3718661 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3718661 times.
3718661 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16950 {
16951 if(isdungeon() && DrunkLeft() && (temp_x==32 && temp_y==80))
16952 {
16953 do
16954 {
16955 info = walkflag(temp_x,temp_y+(bigHitbox?0:8),1,left) ||
16956 walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left);
16957
16958 if(info.isUnwalkable())
16959 {
16960 if(temp_x != int32_t(temp_x))
16961 {
16962 temp_x = floor((double)temp_x);
16963 }
16964 else if(temp_step > 1)
16965 {
16966 if(temp_step != int32_t(temp_step)) //floor
16967 temp_step = floor((double)temp_step);
16968 else --temp_step;
16969 }
16970 else
16971 break;
16972 }
16973 }
16974 while(info.isUnwalkable());
16975
16976 if(!info.isUnwalkable())
16977 {
16978 x = temp_x;
16979 y = temp_y;
16980 hero_newstep = temp_step;
16981 //ONLY process the side-effects of the above walkflag if Hero will actually move
16982 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16983 execute(info);
16984 moveOld2(left);
16985 return;
16986 }
16987 temp_x = x;
16988 temp_y = y;
16989 temp_step = hero_newstep;
16990 }
16991
16992 if(isdungeon() && DrunkRight() && temp_x==208 && temp_y==80)
16993 {
16994 do
16995 {
16996 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16997 walkflag(temp_x+15+temp_step,temp_y+8,1,right);
16998
16999 if(info.isUnwalkable())
17000 {
17001 if(temp_x != int32_t(temp_x))
17002 {
17003 temp_x = floor((double)temp_x);
17004 }
17005 else if(temp_step > 1)
17006 {
17007 if(temp_step != int32_t(temp_step)) //floor
17008 temp_step = floor((double)temp_step);
17009 else --temp_step;
17010 }
17011 else
17012 break;
17013 }
17014 }
17015 while(info.isUnwalkable());
17016
17017 if(!info.isUnwalkable())
17018 {
17019 x = temp_x;
17020 y = temp_y;
17021 hero_newstep = temp_step;
17022 execute(info);
17023 moveOld2(right);
17024 return;
17025 }
17026 temp_x = x;
17027 temp_y = y;
17028 temp_step = hero_newstep;
17029 }
17030
17031 ladderx = oldladderx;
17032 laddery = oldladdery;
17033
17034 if(DrunkUp())
17035 {
17036 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17037 {
17038 if(dir!=up && dir!=down)
17039 {
17040 if(xoff>2&&xoff<6)
17041 {
17042 moveOld2(dir);
17043 }
17044 else if(xoff>=6)
17045 {
17046 moveOld2(right);
17047 }
17048 else if(xoff>=1)
17049 {
17050 moveOld2(left);
17051 }
17052 }
17053 else
17054 {
17055 if(xoff>=4)
17056 {
17057 moveOld2(right);
17058 }
17059 else if(xoff<4)
17060 {
17061 moveOld2(left);
17062 }
17063 }
17064 }
17065 else
17066 {
17067 do
17068 {
17069 if(action==swimming || IsSideSwim() || action == swimhit)
17070 {
17071 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
17072
17073 if(_walkflag(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, 1,SWITCHBLOCK_STATE) &&
17074 !(iswaterex(MAPCOMBO(temp_x, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x, temp_y+(bigHitbox?0:8)-temp_step, true, false) &&
17075 iswaterex(MAPCOMBO(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, true, false)))
17076 info.setUnwalkable(true);
17077 }
17078 else
17079 {
17080 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
17081 if(x.getInt() & 7)
17082 info = info || walkflag(temp_x+16,temp_y+(bigHitbox?0:8)-temp_step,1,up);
17083 else
17084 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
17085 }
17086
17087 if(info.isUnwalkable())
17088 {
17089 if(temp_y != int32_t(temp_y))
17090 {
17091 temp_y = floor((double)temp_y);
17092 }
17093 else if(temp_step > 1)
17094 {
17095 if(temp_step != int32_t(temp_step)) //floor
17096 temp_step = floor((double)temp_step);
17097 else --temp_step;
17098 }
17099 else
17100 break;
17101 }
17102 }
17103 while(info.isUnwalkable());
17104
17105 execute(info);
17106
17107 if(!info.isUnwalkable())
17108 {
17109 x = temp_x;
17110 y = temp_y;
17111 hero_newstep = temp_step;
17112 moveOld2(up);
17113 return;
17114 }
17115
17116 if(!DrunkLeft() && !DrunkRight())
17117 {
17118 if(NO_GRIDLOCK)
17119 {
17120 x = x.getInt();
17121 y = y.getInt();
17122 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17123 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17124 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
17125 {
17126 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
17127 sprite::move((zfix)-1,(zfix)0);
17128 }
17129 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17130 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17131 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
17132 {
17133 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
17134 sprite::move((zfix)1,(zfix)0);
17135 }
17136 else
17137 {
17138 pushing=push+1;
17139 }
17140 }
17141 else pushing=push+1;
17142
17143 if(charging==0 && spins==0)
17144 {
17145 dir=up;
17146 }
17147
17148 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17149 {
17150 herostep();
17151 }
17152
17153 return;
17154 }
17155 else
17156 {
17157 goto LEFTRIGHT_NEWMOVE;
17158 }
17159 }
17160
17161 return;
17162 }
17163
17164 if(DrunkDown())
17165 {
17166 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17167 {
17168 if(dir!=up && dir!=down)
17169 {
17170 if(xoff>2&&xoff<6)
17171 {
17172 moveOld2(dir);
17173 }
17174 else if(xoff>=6)
17175 {
17176 moveOld2(right);
17177 }
17178 else if(xoff>=1)
17179 {
17180 moveOld2(left);
17181 }
17182 }
17183 else
17184 {
17185 if(xoff>=4)
17186 {
17187 moveOld2(right);
17188 }
17189 else if(xoff<4)
17190 {
17191 moveOld2(left);
17192 }
17193 }
17194 }
17195 else
17196 {
17197 do
17198 {
17199 if(action==swimming || IsSideSwim() || action == swimhit)
17200 {
17201 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
17202
17203 if(_walkflag(temp_x+15, temp_y+15+temp_step, 1,SWITCHBLOCK_STATE) &&
17204 !(iswaterex(MAPCOMBO(temp_x, temp_y+15+temp_step), currmap, currscr, -1, temp_x, temp_y+15+temp_step, true, false) &&
17205 iswaterex(MAPCOMBO(temp_x+15, temp_y+15+temp_step), currmap, currscr, -1, temp_x+15, temp_y+15+temp_step, true, false)))
17206 info.setUnwalkable(true);
17207 }
17208 else
17209 {
17210 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
17211 if(x.getInt() & 7)
17212 info = info || walkflag(temp_x+16,temp_y+15+temp_step,1,down);
17213 else
17214 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
17215 }
17216
17217 if(info.isUnwalkable())
17218 {
17219 if(temp_y != int32_t(temp_y))
17220 {
17221 temp_y = floor((double)temp_y);
17222 }
17223 else if(temp_step > 1)
17224 {
17225 if(temp_step != int32_t(temp_step)) //floor
17226 temp_step = floor((double)temp_step);
17227 else --temp_step;
17228 }
17229 else
17230 break;
17231 }
17232 }
17233 while(info.isUnwalkable());
17234
17235 execute(info);
17236
17237 if(!info.isUnwalkable())
17238 {
17239 x = temp_x;
17240 y = temp_y;
17241 hero_newstep = temp_step;
17242 moveOld2(down);
17243 return;
17244 }
17245
17246 if(!DrunkLeft() && !DrunkRight())
17247 {
17248 if(NO_GRIDLOCK)
17249 {
17250 x = x.getInt();
17251 y = y.getInt();
17252 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
17253 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
17254 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
17255 {
17256 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
17257 sprite::move((zfix)-1,(zfix)0);
17258 }
17259 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
17260 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
17261 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
17262 {
17263 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
17264 sprite::move((zfix)1,(zfix)0);
17265 }
17266 else
17267 {
17268 pushing=push+1;
17269 }
17270 }
17271 else pushing=push+1;
17272
17273 if(charging==0 && spins==0)
17274 {
17275 dir=down;
17276 }
17277
17278 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17279 {
17280 herostep();
17281 }
17282
17283 return;
17284 }
17285 else goto LEFTRIGHT_NEWMOVE;
17286 }
17287
17288 return;
17289 }
17290
17291 LEFTRIGHT_NEWMOVE:
17292 temp_x = x;
17293 temp_y = y;
17294 temp_step = hero_newstep;
17295 if(isdungeon() && (temp_y<=26 || temp_y>=134) && !get_qr(qr_FREEFORM) && !toogam)
17296 {
17297 return;
17298 }
17299
17300 if(DrunkLeft())
17301 {
17302 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17303 {
17304 if(dir!=left && dir!=right)
17305 {
17306 if(yoff>2&&yoff<6)
17307 {
17308 moveOld2(dir);
17309 }
17310 else if(yoff>=6)
17311 {
17312 moveOld2(down);
17313 }
17314 else if(yoff>=1)
17315 {
17316 moveOld2(up);
17317 }
17318 }
17319 else
17320 {
17321 if(yoff>=4)
17322 {
17323 moveOld2(down);
17324 }
17325 else if(yoff<4)
17326 {
17327 moveOld2(up);
17328 }
17329 }
17330 }
17331 else
17332 {
17333 do
17334 {
17335 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) ||
17336 walkflag(temp_x-temp_step,temp_y+(isSideViewHero() ?0:8), 1,left);
17337
17338 if(y.getInt() & 7)
17339 info = info || walkflag(temp_x-temp_step,temp_y+16,1,left);
17340
17341 if(info.isUnwalkable())
17342 {
17343 if(temp_x != int32_t(temp_x))
17344 {
17345 temp_x = floor((double)temp_x);
17346 }
17347 else if(temp_step > 1)
17348 {
17349 if(temp_step != int32_t(temp_step)) //floor
17350 temp_step = floor((double)temp_step);
17351 else --temp_step;
17352 }
17353 else
17354 break;
17355 }
17356 }
17357 while(info.isUnwalkable());
17358
17359 execute(info);
17360
17361 if(!info.isUnwalkable())
17362 {
17363 x = temp_x;
17364 y = temp_y;
17365 hero_newstep = temp_step;
17366 moveOld2(left);
17367 return;
17368 }
17369
17370 if(!DrunkUp() && !DrunkDown())
17371 {
17372 if(NO_GRIDLOCK)
17373 {
17374 x = x.getInt();
17375 y = y.getInt();
17376 int32_t v1=bigHitbox?0:8;
17377 int32_t v2=bigHitbox?8:12;
17378
17379 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
17380 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
17381 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
17382 {
17383 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17384 sprite::move((zfix)0,(zfix)-1);
17385 }
17386 else if(_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
17387 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
17388 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
17389 {
17390 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17391 sprite::move((zfix)0,(zfix)1);
17392 }
17393 else
17394 {
17395 pushing=push+1;
17396 }
17397 }
17398 else pushing=push+1;
17399
17400 if(charging==0 && spins==0)
17401 {
17402 dir=left;
17403 }
17404
17405 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17406 {
17407 herostep();
17408 }
17409
17410 return;
17411 }
17412 }
17413
17414 return;
17415 }
17416
17417 if(DrunkRight())
17418 {
17419 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17420 {
17421 if(dir!=left && dir!=right)
17422 {
17423 if(yoff>2&&yoff<6)
17424 {
17425 moveOld2(dir);
17426 }
17427 else if(yoff>=6)
17428 {
17429 moveOld2(down);
17430 }
17431 else if(yoff>=1)
17432 {
17433 moveOld2(up);
17434 }
17435 }
17436 else
17437 {
17438 if(yoff>=4)
17439 {
17440 moveOld2(down);
17441 }
17442 else if(yoff<4)
17443 {
17444 moveOld2(up);
17445 }
17446 }
17447 }
17448 else
17449 {
17450 do
17451 {
17452 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
17453 walkflag(temp_x+15+temp_step,temp_y+(isSideViewHero() ?0:8),1,right);
17454
17455 if(y.getInt() & 7)
17456 info = info || walkflag(temp_x+15+temp_step,y+16,1,right);
17457
17458 if(info.isUnwalkable())
17459 {
17460 if(temp_x != int32_t(temp_x))
17461 {
17462 temp_x = floor((double)temp_x);
17463 }
17464 else if(temp_step > 1)
17465 {
17466 if(temp_step != int32_t(temp_step)) //floor
17467 temp_step = floor((double)temp_step);
17468 else --temp_step;
17469 }
17470 else
17471 break;
17472 }
17473 }
17474 while(info.isUnwalkable());
17475
17476 execute(info);
17477
17478 if(!info.isUnwalkable())
17479 {
17480 x = temp_x;
17481 y = temp_y;
17482 hero_newstep = temp_step;
17483 moveOld2(right);
17484 return;
17485 }
17486
17487 if(!DrunkUp() && !DrunkDown())
17488 {
17489 if(NO_GRIDLOCK)
17490 {
17491 x = x.getInt();
17492 y = y.getInt();
17493 int32_t v1=bigHitbox?0:8;
17494 int32_t v2=bigHitbox?8:12;
17495
17496 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
17497 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
17498 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
17499 {
17500 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17501 sprite::move((zfix)0,(zfix)-1);
17502 }
17503 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
17504 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
17505 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
17506 {
17507 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17508 sprite::move((zfix)0,(zfix)1);
17509 }
17510 else
17511 {
17512 pushing=push+1;
17513 }
17514 }
17515 else pushing=push+1;
17516
17517 if(charging==0 && spins==0)
17518 {
17519 dir=right;
17520 }
17521
17522 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17523 {
17524 herostep();
17525 }
17526
17527 return;
17528 }
17529 }
17530 }
17531 }
17532 else
17533 {
17534 7437322 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
17535 3718661 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
17536
17537
10/10
✓ Branch 0 taken 2412266 times.
✓ Branch 1 taken 1306395 times.
✓ Branch 2 taken 304260 times.
✓ Branch 3 taken 2108006 times.
✓ Branch 4 taken 186351 times.
✓ Branch 5 taken 117909 times.
✓ Branch 6 taken 1889 times.
✓ Branch 7 taken 184462 times.
✓ Branch 8 taken 358 times.
✓ Branch 9 taken 1531 times.
3718661 if(isdungeon() && DrunkLeft() && !info.isUnwalkable() && (x==32 && y==80))
17538 {
17539 //ONLY process the side-effects of the above walkflag if Hero will actually move
17540 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
17541 1531 execute(info);
17542 1531 moveOld2(left);
17543 1531 return;
17544 }
17545
17546 7434260 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) ||
17547 3717130 walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
17548
17549
10/10
✓ Branch 0 taken 2410735 times.
✓ Branch 1 taken 1306395 times.
✓ Branch 2 taken 337875 times.
✓ Branch 3 taken 2072860 times.
✓ Branch 4 taken 201206 times.
✓ Branch 5 taken 136669 times.
✓ Branch 6 taken 2221 times.
✓ Branch 7 taken 198985 times.
✓ Branch 8 taken 406 times.
✓ Branch 9 taken 1815 times.
3717130 if(isdungeon() && DrunkRight() && !info.isUnwalkable() && x==208 && y==80)
17550 {
17551 1815 execute(info);
17552 1815 moveOld2(right);
17553 1815 return;
17554 }
17555
17556 3715315 ladderx = oldladderx;
17557 3715315 laddery = oldladdery;
17558
17559
2/2
✓ Branch 0 taken 416012 times.
✓ Branch 1 taken 3299303 times.
3715315 if(DrunkUp())
17560 {
17561
11/14
✓ Branch 0 taken 11758 times.
✓ Branch 1 taken 404254 times.
✓ Branch 2 taken 10987 times.
✓ Branch 3 taken 771 times.
✓ Branch 4 taken 8232 times.
✓ Branch 5 taken 2755 times.
✓ Branch 6 taken 8232 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8232 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 8232 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 8229 times.
416012 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17562 {
17563
4/4
✓ Branch 0 taken 8195 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 8194 times.
8229 if(dir!=up && dir!=down)
17564 {
17565
4/4
✓ Branch 0 taken 5693 times.
✓ Branch 1 taken 2501 times.
✓ Branch 2 taken 2427 times.
✓ Branch 3 taken 3266 times.
8194 if(xoff>2&&xoff<6)
17566 {
17567 3266 moveOld2(dir);
17568 3266 }
17569
2/2
✓ Branch 0 taken 2427 times.
✓ Branch 1 taken 2501 times.
4928 else if(xoff>=6)
17570 {
17571 2427 moveOld2(right);
17572 2427 }
17573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2501 times.
2501 else if(xoff>=1)
17574 {
17575 2501 moveOld2(left);
17576 2501 }
17577 8194 }
17578 else
17579 {
17580
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 25 times.
35 if(xoff>=4)
17581 {
17582 10 moveOld2(right);
17583 10 }
17584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 else if(xoff<4)
17585 {
17586 25 moveOld2(left);
17587 25 }
17588 }
17589 8229 }
17590 else
17591 {
17592
4/6
✓ Branch 0 taken 381403 times.
✓ Branch 1 taken 26380 times.
✓ Branch 2 taken 381403 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 381403 times.
407783 if(action==swimming || IsSideSwim() || action == swimhit)
17593 {
17594 26380 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
17595
17596
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 26380 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26380 times.
✓ Branch 4 taken 2023 times.
✓ Branch 5 taken 24357 times.
✓ Branch 6 taken 21669 times.
✓ Branch 7 taken 4711 times.
50737 if(_walkflag(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
17597
2/2
✓ Branch 0 taken 4471 times.
✓ Branch 1 taken 19886 times.
44243 !(iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])) &&
17598 19886 iswaterex(MAPCOMBO(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]))))
17599 4711 info.setUnwalkable(true);
17600 26380 }
17601 else
17602 {
17603 381403 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
17604
2/2
✓ Branch 0 taken 777 times.
✓ Branch 1 taken 380626 times.
381403 if(x.getInt() & 7)
17605 777 info = info || walkflag(x+16,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),1,up);
17606 else
17607 380626 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
17608 }
17609
17610 407783 execute(info);
17611
17612
2/2
✓ Branch 0 taken 169866 times.
✓ Branch 1 taken 237917 times.
407783 if(!info.isUnwalkable())
17613 {
17614 237917 moveOld2(up);
17615 237917 return;
17616 }
17617
17618
4/4
✓ Branch 0 taken 151084 times.
✓ Branch 1 taken 18782 times.
✓ Branch 2 taken 18777 times.
✓ Branch 3 taken 132307 times.
169866 if(!DrunkLeft() && !DrunkRight())
17619 {
17620
2/4
✓ Branch 0 taken 132307 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 132307 times.
132307 if(NO_GRIDLOCK)
17621 {
17622 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17623 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17624 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
17625 {
17626 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
17627 sprite::move((zfix)-1,(zfix)0);
17628 }
17629 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17630 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17631 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
17632 {
17633 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
17634 sprite::move((zfix)1,(zfix)0);
17635 }
17636 else
17637 {
17638 pushing=push+1;
17639 }
17640 }
17641 132307 else pushing=push+1;
17642
17643
4/4
✓ Branch 0 taken 132124 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 132028 times.
132307 if(charging==0 && spins==0)
17644 {
17645 132028 dir=up;
17646 132028 }
17647
17648
5/8
✓ Branch 0 taken 129280 times.
✓ Branch 1 taken 3027 times.
✓ Branch 2 taken 129280 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 129280 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 129280 times.
132307 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17649 {
17650 129280 herostep();
17651 129280 }
17652
17653 132307 return;
17654 }
17655 else
17656 {
17657 37559 goto LEFTRIGHT_OLDMOVE;
17658 }
17659 }
17660
17661 8229 return;
17662 }
17663
17664
2/2
✓ Branch 0 taken 370268 times.
✓ Branch 1 taken 2929035 times.
3299303 if(DrunkDown())
17665 {
17666
11/14
✓ Branch 0 taken 10692 times.
✓ Branch 1 taken 359576 times.
✓ Branch 2 taken 9973 times.
✓ Branch 3 taken 719 times.
✓ Branch 4 taken 6692 times.
✓ Branch 5 taken 3281 times.
✓ Branch 6 taken 6692 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6692 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6692 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 6691 times.
370268 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17667 {
17668
3/4
✓ Branch 0 taken 6691 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 6688 times.
6691 if(dir!=up && dir!=down)
17669 {
17670
4/4
✓ Branch 0 taken 4674 times.
✓ Branch 1 taken 2014 times.
✓ Branch 2 taken 2000 times.
✓ Branch 3 taken 2674 times.
6688 if(xoff>2&&xoff<6)
17671 {
17672 2674 moveOld2(dir);
17673 2674 }
17674
2/2
✓ Branch 0 taken 2000 times.
✓ Branch 1 taken 2014 times.
4014 else if(xoff>=6)
17675 {
17676 2000 moveOld2(right);
17677 2000 }
17678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2014 times.
2014 else if(xoff>=1)
17679 {
17680 2014 moveOld2(left);
17681 2014 }
17682 6688 }
17683 else
17684 {
17685
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(xoff>=4)
17686 {
17687 3 moveOld2(right);
17688 3 }
17689 else if(xoff<4)
17690 {
17691 moveOld2(left);
17692 }
17693 }
17694 6691 }
17695 else
17696 {
17697
4/6
✓ Branch 0 taken 340051 times.
✓ Branch 1 taken 23526 times.
✓ Branch 2 taken 340051 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 340051 times.
363577 if(action==swimming || IsSideSwim() || action == swimhit)
17698 {
17699 23526 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
17700
17701
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 23526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23526 times.
✓ Branch 4 taken 2312 times.
✓ Branch 5 taken 21214 times.
✓ Branch 6 taken 17545 times.
✓ Branch 7 taken 5981 times.
44740 if(_walkflag(x+15, y+15+int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
17702
2/2
✓ Branch 0 taken 5786 times.
✓ Branch 1 taken 15428 times.
36642 !(iswaterex(MAPCOMBO(x, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+15+int32_t(lsteps[y.getInt()&7])) &&
17703 15428 iswaterex(MAPCOMBO(x+15, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+15+int32_t(lsteps[y.getInt()&7]))))
17704 5981 info.setUnwalkable(true);
17705 23526 }
17706 else
17707 {
17708 340051 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
17709
2/2
✓ Branch 0 taken 724 times.
✓ Branch 1 taken 339327 times.
340051 if(x.getInt() & 7)
17710 724 info = (info || walkflag(x+16,y+15+int32_t(lsteps[y.getInt()&7]),1,down));
17711 else
17712 339327 info = (info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7])));
17713 }
17714
17715 363577 execute(info);
17716
17717
2/2
✓ Branch 0 taken 167095 times.
✓ Branch 1 taken 196482 times.
363577 if(!info.isUnwalkable())
17718 {
17719 196482 moveOld2(down);
17720 196482 return;
17721 }
17722
17723
4/4
✓ Branch 0 taken 146281 times.
✓ Branch 1 taken 20814 times.
✓ Branch 2 taken 20409 times.
✓ Branch 3 taken 125872 times.
167095 if(!DrunkLeft() && !DrunkRight())
17724 {
17725
2/4
✓ Branch 0 taken 125872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125872 times.
125872 if(NO_GRIDLOCK)
17726 {
17727 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
17728 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
17729 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
17730 {
17731 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
17732 sprite::move((zfix)-1,(zfix)0);
17733 }
17734 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
17735 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
17736 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
17737 {
17738 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
17739 sprite::move((zfix)1,(zfix)0);
17740 }
17741 else
17742 {
17743 pushing=push+1;
17744 }
17745 }
17746 125872 else pushing=push+1;
17747
17748
2/4
✓ Branch 0 taken 125872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125872 times.
125872 if(charging==0 && spins==0)
17749 {
17750 125872 dir=down;
17751 125872 }
17752
17753
5/8
✓ Branch 0 taken 123206 times.
✓ Branch 1 taken 2666 times.
✓ Branch 2 taken 123206 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 123206 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 123206 times.
125872 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17754 {
17755 123206 herostep();
17756 123206 }
17757
17758 125872 return;
17759 }
17760 41223 else goto LEFTRIGHT_OLDMOVE;
17761 }
17762
17763 6691 return;
17764 }
17765
17766 LEFTRIGHT_OLDMOVE:
17767
17768
7/8
✓ Branch 0 taken 2014752 times.
✓ Branch 1 taken 1052471 times.
✓ Branch 2 taken 1959398 times.
✓ Branch 3 taken 55354 times.
✓ Branch 4 taken 55639 times.
✓ Branch 5 taken 1959113 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 55639 times.
3067223 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam)
17769 {
17770 55639 return;
17771 }
17772
17773
2/2
✓ Branch 0 taken 462595 times.
✓ Branch 1 taken 2548989 times.
3011584 if(DrunkLeft())
17774 {
17775
11/14
✓ Branch 0 taken 8414 times.
✓ Branch 1 taken 454181 times.
✓ Branch 2 taken 7961 times.
✓ Branch 3 taken 453 times.
✓ Branch 4 taken 7342 times.
✓ Branch 5 taken 619 times.
✓ Branch 6 taken 7342 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7342 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7342 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 7340 times.
462595 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17776 {
17777
3/4
✓ Branch 0 taken 7331 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7331 times.
7340 if(dir!=left && dir!=right)
17778 {
17779
4/4
✓ Branch 0 taken 5179 times.
✓ Branch 1 taken 2152 times.
✓ Branch 2 taken 2239 times.
✓ Branch 3 taken 2940 times.
7331 if(yoff>2&&yoff<6)
17780 {
17781 2940 moveOld2(dir);
17782 2940 }
17783
2/2
✓ Branch 0 taken 2239 times.
✓ Branch 1 taken 2152 times.
4391 else if(yoff>=6)
17784 {
17785 2239 moveOld2(down);
17786 2239 }
17787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2152 times.
2152 else if(yoff>=1)
17788 {
17789 2152 moveOld2(up);
17790 2152 }
17791 7331 }
17792 else
17793 {
17794
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 if(yoff>=4)
17795 {
17796 6 moveOld2(down);
17797 6 }
17798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 else if(yoff<4)
17799 {
17800 3 moveOld2(up);
17801 3 }
17802 }
17803 7340 }
17804 else
17805 {
17806 910510 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
17807 455255 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero() ?0:8), 1,left);
17808
17809 455255 execute(info);
17810
17811
2/2
✓ Branch 0 taken 164044 times.
✓ Branch 1 taken 291211 times.
455255 if(!info.isUnwalkable())
17812 {
17813 291211 moveOld2(left);
17814 291211 return;
17815 }
17816
17817
4/4
✓ Branch 0 taken 156032 times.
✓ Branch 1 taken 8012 times.
✓ Branch 2 taken 8593 times.
✓ Branch 3 taken 147439 times.
164044 if(!DrunkUp() && !DrunkDown())
17818 {
17819
2/4
✓ Branch 0 taken 147439 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 147439 times.
147439 if(NO_GRIDLOCK)
17820 {
17821 int32_t v1=bigHitbox?0:8;
17822 int32_t v2=bigHitbox?8:12;
17823
17824 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
17825 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
17826 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
17827 {
17828 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17829 sprite::move((zfix)0,(zfix)-1);
17830 }
17831 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
17832 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
17833 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
17834 {
17835 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17836 sprite::move((zfix)0,(zfix)1);
17837 }
17838 else
17839 {
17840 pushing=push+1;
17841 }
17842 }
17843 147439 else pushing=push+1;
17844
17845
3/4
✓ Branch 0 taken 147433 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 147433 times.
147439 if(charging==0 && spins==0)
17846 {
17847 147433 dir=left;
17848 147433 }
17849
17850
5/8
✓ Branch 0 taken 143644 times.
✓ Branch 1 taken 3795 times.
✓ Branch 2 taken 143644 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 143644 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 143644 times.
147439 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17851 {
17852 143644 herostep();
17853 143644 }
17854
17855 147439 return;
17856 }
17857 }
17858
17859 23945 return;
17860 }
17861
17862
2/2
✓ Branch 0 taken 2047217 times.
✓ Branch 1 taken 501772 times.
2548989 if(DrunkRight())
17863 {
17864
10/14
✓ Branch 0 taken 8228 times.
✓ Branch 1 taken 493544 times.
✓ Branch 2 taken 7619 times.
✓ Branch 3 taken 609 times.
✓ Branch 4 taken 7421 times.
✓ Branch 5 taken 198 times.
✓ Branch 6 taken 7421 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7421 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7421 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 7421 times.
501772 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17865 {
17866
4/4
✓ Branch 0 taken 7418 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 7409 times.
7421 if(dir!=left && dir!=right)
17867 {
17868
4/4
✓ Branch 0 taken 5268 times.
✓ Branch 1 taken 2141 times.
✓ Branch 2 taken 2234 times.
✓ Branch 3 taken 3034 times.
7409 if(yoff>2&&yoff<6)
17869 {
17870 3034 moveOld2(dir);
17871 3034 }
17872
2/2
✓ Branch 0 taken 2234 times.
✓ Branch 1 taken 2141 times.
4375 else if(yoff>=6)
17873 {
17874 2234 moveOld2(down);
17875 2234 }
17876
1/2
✓ Branch 0 taken 2141 times.
✗ Branch 1 not taken.
2141 else if(yoff>=1)
17877 {
17878 2141 moveOld2(up);
17879 2141 }
17880 7409 }
17881 else
17882 {
17883
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if(yoff>=4)
17884 {
17885 6 moveOld2(down);
17886 6 }
17887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(yoff<4)
17888 {
17889 6 moveOld2(up);
17890 6 }
17891 }
17892 7421 }
17893 else
17894 {
17895 988702 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right)
17896 494351 || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero()?0:8),1,right);
17897
17898 494351 execute(info);
17899
17900
2/2
✓ Branch 0 taken 181171 times.
✓ Branch 1 taken 313180 times.
494351 if(!info.isUnwalkable())
17901 {
17902 313180 moveOld2(right);
17903 313180 return;
17904 }
17905
17906
4/4
✓ Branch 0 taken 174552 times.
✓ Branch 1 taken 6619 times.
✓ Branch 2 taken 8011 times.
✓ Branch 3 taken 166541 times.
181171 if(!DrunkUp() && !DrunkDown())
17907 {
17908
2/4
✓ Branch 0 taken 166541 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 166541 times.
166541 if(NO_GRIDLOCK)
17909 {
17910 int32_t v1=bigHitbox?0:8;
17911 int32_t v2=bigHitbox?8:12;
17912
17913 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
17914 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
17915 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
17916 {
17917 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17918 sprite::move((zfix)0,(zfix)-1);
17919 }
17920 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
17921 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
17922 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
17923 {
17924 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17925 sprite::move((zfix)0,(zfix)1);
17926 }
17927 else
17928 {
17929 pushing=push+1;
17930 }
17931 }
17932 166541 else pushing=push+1;
17933
17934
2/4
✓ Branch 0 taken 166541 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 166541 times.
166541 if(charging==0 && spins==0)
17935 {
17936 166541 dir=right;
17937 166541 }
17938
17939
5/8
✓ Branch 0 taken 164947 times.
✓ Branch 1 taken 1594 times.
✓ Branch 2 taken 164947 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 164947 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 164947 times.
166541 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17940 {
17941 164947 herostep();
17942 164947 }
17943
17944 166541 return;
17945 }
17946 }
17947 22051 }
17948 }
17949 13169753 }
17950
17951 4466262 bool HeroClass::scr_walkflag(zfix_round zdx,zfix_round zdy,int d2,bool kb, int* canladder)
17952 {
17953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4466262 times.
4466262 if(toogam) return false;
17954 4466262 int dx = zdx.getRound(), dy = zdy.getRound();
17955
17956
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4466262 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4466262 if(blockpath && dy<80) //Blocked top parts of rooms
17957 return true;
17958
17959
4/4
✓ Branch 0 taken 30097 times.
✓ Branch 1 taken 4436165 times.
✓ Branch 2 taken 18818 times.
✓ Branch 3 taken 11279 times.
4466262 if(mblock2.active() && mblock2.hit(dx,dy,0,1,1,1))
17960 11279 return true;
17961 //collide_object handled in scr_canmove
17962
17963
4/6
✓ Branch 0 taken 683926 times.
✓ Branch 1 taken 3771057 times.
✓ Branch 2 taken 683926 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4454983 times.
4478762 if(isdungeon() && currscr<128 && dy<40
17964
5/10
✓ Branch 0 taken 23779 times.
✓ Branch 1 taken 660147 times.
✓ Branch 2 taken 13692 times.
✓ Branch 3 taken 10087 times.
✓ Branch 4 taken 13692 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
683926 && ((x<=112||x>=128) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
17965
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
23779 && !get_qr(qr_FREEFORM))
17966 return true; //Old NES dungeon stuff
17967
17968
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4454983 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4454983 times.
4454983 bool solid = _walkflag(zdx,zdy,1,SWITCHBLOCK_STATE);
17969
17970
4/6
✓ Branch 0 taken 683926 times.
✓ Branch 1 taken 3771057 times.
✓ Branch 2 taken 683926 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 683926 times.
✗ Branch 5 not taken.
4454983 if(isdungeon() && currscr<128 && !get_qr(qr_FREEFORM))
17971 {
17972 if(dx>=112&&dx<120&&dy<40&&dy>=32)
17973 solid=true;
17974
17975 if(dx>=136&&dx<144&&dy<40&&dy>=32)
17976 solid=true;
17977 }
17978
17979
3/4
✓ Branch 0 taken 4418204 times.
✓ Branch 1 taken 36779 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4418204 times.
4454983 if(action==swimming || IsSideSwim())
17980 {
17981
2/2
✓ Branch 0 taken 13463 times.
✓ Branch 1 taken 23316 times.
36779 if(!solid)
17982 {
17983 23316 int ls = 22;
17984
1/6
✓ Branch 0 taken 23316 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
23316 if((get_qr(qr_DROWN) && isSwimming()) || (!diagonalMovement) || get_qr(qr_NO_HOPPING))
17985 23316 ls = 1;
17986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23316 times.
23316 if(landswim < ls)
17987 {
17988
2/4
✓ Branch 0 taken 23316 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23316 times.
23316 if(dx<0||dy<0);
17989
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 23296 times.
23316 else if(dx>=256);
17990
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 23278 times.
23296 else if(dy>=176);
17991
2/4
✓ Branch 0 taken 23278 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23278 times.
23278 else if(get_qr(qr_DROWN) && !ilswim);
17992 else if(iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx,dy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
17993 solid = false;
17994 else
17995 solid = true;
17996 23316 }
17997 23316 }
17998 else
17999 {
18000 13463 int32_t wtrx = iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx,dy);
18001
18002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13463 times.
13463 if(wtrx)
18003 solid = false;
18004 }
18005 36779 }
18006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4418204 times.
4418204 else if(ladderx+laddery) // ladder is being used
18007 {
18008 if (canladder)
18009 {
18010 *canladder = 0;
18011 }
18012 int32_t lx = zfix(dx);
18013 int32_t ly = zfix(dy);
18014
18015 if(ladderdir<=down) //vertical ladder
18016 {
18017 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
18018 {
18019 bool temp = false;
18020
18021 if(!(abs(lx-(ladderx+8))<=8))
18022 temp = true;
18023
18024 if(!temp)
18025 {
18026 solid = false;
18027 }
18028 else if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
18029 {
18030 solid = true;
18031 }
18032 }
18033 }
18034 else //horizontal ladder
18035 {
18036 if(abs(lx-(ladderx+8))<=8)
18037 {
18038 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
18039 {
18040 solid = false;
18041 }
18042 else if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
18043 {
18044 solid = true;
18045 }
18046 else if((abs(ly-laddery+8)<=8) && d2<=down)
18047 {
18048 solid = false;
18049 }
18050 }
18051 }
18052 }
18053
5/6
✓ Branch 0 taken 2170631 times.
✓ Branch 1 taken 2247573 times.
✓ Branch 2 taken 2169359 times.
✓ Branch 3 taken 1272 times.
✓ Branch 4 taken 2169359 times.
✗ Branch 5 not taken.
4418204 else if(solid || isSideViewHero() || get_qr(qr_DROWN))
18054 {
18055 // see if it's a good spot for the ladder or for swimming
18056
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4418204 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4418204 times.
4418204 bool unwalkablex = _walkflag(zdx,zdy,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
18057
18058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4418204 times.
4418204 if(get_qr(qr_DROWN))
18059 {
18060 // Drowning changes the following attributes:
18061 // * Dangerous water is also walkable, so ignore the previous
18062 // definitions of unwalkablex.
18063 // * Instead, prevent the ladder from being used in the
18064 // one frame where Hero has landed on water before drowning.
18065 4418204 unwalkablex = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
18066 4418204 }
18067
18068 // check if he can swim
18069
4/6
✓ Branch 0 taken 431459 times.
✓ Branch 1 taken 3986745 times.
✓ Branch 2 taken 431459 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 431459 times.
4418204 if(current_item(itype_flippers) && z==0 && fakez==0)
18070 {
18071 431459 int32_t wtrx = iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx,dy);
18072
5/6
✓ Branch 0 taken 431285 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 893 times.
✓ Branch 3 taken 430392 times.
✓ Branch 4 taken 893 times.
✗ Branch 5 not taken.
431459 if (current_item(itype_flippers) >= combobuf[wtrx].attribytes[0] && (!(combobuf[wtrx].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & item_flag3))) //Don't swim if the water's required level is too high! -Dimi
18073 {
18074 //ladder ignores water combos that are now walkable thanks to flippers -DD
18075
2/2
✓ Branch 0 taken 4582 times.
✓ Branch 1 taken 426703 times.
431285 unwalkablex = unwalkablex && (!wtrx);
18076
18077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431285 times.
431285 if(landswim >= 22)
18078 {
18079 solid = false;
18080 }
18081
2/2
✓ Branch 0 taken 426943 times.
✓ Branch 1 taken 4342 times.
431285 else if(wtrx)
18082 {
18083
2/2
✓ Branch 0 taken 1000 times.
✓ Branch 1 taken 3342 times.
4342 if(dir==d2)
18084 {
18085 3342 ladderx = 0;
18086 3342 laddery = 0;
18087 3342 }
18088 4342 }
18089 431285 }
18090 431459 }
18091
18092 // check if he can use the ladder
18093 // "Allow Ladder Anywhere" is toggled by fLADDER
18094
1/2
✓ Branch 0 taken 4418204 times.
✗ Branch 1 not taken.
4418204 if(can_deploy_ladder())
18095 // laddersetup
18096 {
18097 // Check if there's water to use the ladder over
18098 bool wtrx = (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx,dy) != 0);
18099 int32_t ldrid = current_item_id(itype_ladder);
18100 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&item_flag1);
18101
18102 if(wtrx)
18103 {
18104 if(isSideViewHero())
18105 {
18106 wtrx = !_walkflag(zdx, zdy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(dx, dy, 1,SWITCHBLOCK_STATE) && dir!=down;
18107 }
18108 // * walk on half-water using the ladder instead of using flippers.
18109 // * otherwise, walk on ladder(+hookshot) combos.
18110 else if((isstepable(MAPCOMBO(dx, dy)) || wtrx==true))
18111 {
18112 if(!get_qr(qr_OLD_210_WATER) && current_item(itype_flippers))
18113 {
18114 //if Hero could swim on a tile instead of using the ladder,
18115 //refuse to use the ladder to step over that tile. -DD
18116 wtrx = isstepable(MAPCOMBO(dx, dy)) && unwalkablex;
18117 }
18118 }
18119 }
18120 else
18121 {
18122 // No water; check other things
18123
18124 //Check pits
18125 if(ladderpits)
18126 {
18127 int32_t pit_cmb = getpitfall(dx,dy);
18128 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
18129 }
18130 if(!ladderpits || (!wtrx || isSideViewHero())) //If no pit, check ladder combos
18131 {
18132 int32_t combo=combobuf[MAPCOMBO(dx, dy)].type;
18133 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
18134 }
18135 }
18136
18137 for (int32_t i = 0; i <= 1; ++i)
18138 {
18139 if(tmpscr2[i].valid!=0)
18140 {
18141 if (get_qr(qr_OLD_BRIDGE_COMBOS))
18142 {
18143 if (combobuf[MAPCOMBO2(i,dx,dy)].type == cBRIDGE && !_walkflag_layer(dx,dy,1, &(tmpscr2[i]))) wtrx = false;
18144 }
18145 else
18146 {
18147 if (combobuf[MAPCOMBO2(i,dx,dy)].type == cBRIDGE && _effectflag_layer(dx,dy,1, &(tmpscr2[i]))) wtrx = false;
18148 }
18149 }
18150 }
18151 bool walkwater = (get_qr(qr_DROWN) && !iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx,dy));
18152
18153 if (!wtrx && solid)
18154 {
18155 if (canladder)
18156 {
18157 *canladder = 0;
18158 }
18159 }
18160
18161 if(d2==dir)
18162 {
18163 int32_t c = walkwater ? 0:8;
18164 int32_t b = walkwater ? 8:0;
18165
18166 if(d2>=left)
18167 {
18168 if (wtrx)
18169 {
18170 //If the difference between dy and y is small enough
18171 //this is apparently a really crappy corner shove check?
18172 if((replay_version_check(26)) || (abs((dy)-(int32_t(y+c)))<=(b)))
18173 {
18174 // Don't activate the ladder if it would be entirely
18175 // over water and Hero has the flippers. This isn't
18176 // a good way to do this, but it's too risky
18177 // to make big changes to this stuff.
18178 bool deployLadder=true;
18179 int32_t lx=dx&0xF0;
18180 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
18181 {
18182 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
18183 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
18184 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
18185 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
18186 deployLadder=false;
18187 }
18188 if(deployLadder)
18189 {
18190 if (replay_version_check(26))
18191 {
18192 if (canladder)
18193 {
18194 if (*canladder == -1) *canladder = 1;
18195 }
18196 }
18197 else
18198 {
18199 ladderx = dx&0xF0;
18200 laddery = y;
18201 ladderdir = left;
18202 ladderstart = d2;
18203 solid = laddery!=y.getInt();
18204 }
18205 }
18206 }
18207 }
18208 }
18209 else if(d2<=down)
18210 {
18211 if (wtrx)
18212 {
18213 //Unsure if this actually needs a replay check but better safe than sorry?
18214 if (replay_version_check(26))
18215 {
18216 if (canladder)
18217 {
18218 if (*canladder == -1) *canladder = 1;
18219 }
18220 }
18221 // If the difference between dx and x is small enough
18222 if(!replay_version_check(26) && (abs((dx)-(int32_t(x+c)))<=(b)))
18223 {
18224 ladderx = x;
18225 laddery = dy&0xF0;
18226 ladderdir = up;
18227 ladderstart = d2;
18228 solid = ladderx!=x.getInt();
18229 }
18230 }
18231 }
18232 }
18233 }
18234 4418204 }
18235
18236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4454983 times.
4454983 if (replay_version_check(26))
18237 {
18238
2/2
✓ Branch 0 taken 3236567 times.
✓ Branch 1 taken 1218416 times.
4454983 if (canladder)
18239 {
18240
3/4
✓ Branch 0 taken 1360225 times.
✓ Branch 1 taken 1876342 times.
✓ Branch 2 taken 1360225 times.
✗ Branch 3 not taken.
3236567 if (solid && *canladder == 1) *canladder = 2;
18241 3236567 }
18242 4454983 }
18243
18244 4454983 return solid;
18245 4466262 }
18246
18247 1473285 bool HeroClass::scr_canmove(zfix dx, zfix dy, bool kb, bool ign_sv, int* canladder)
18248 {
18249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1473285 times.
1473285 if(toogam) return true;
18250
3/4
✓ Branch 0 taken 716491 times.
✓ Branch 1 taken 756794 times.
✓ Branch 2 taken 716491 times.
✗ Branch 3 not taken.
1473285 if(!(dx || dy)) return true;
18251 1473285 zfix bx = x, by = y+(bigHitbox?0:8); //left/top
18252 1473285 zfix rx = x+15.9999_zf, ry = y+15.9999_zf; //right/bottom
18253 1473285 zfix wid = 16, hei = bigHitbox ? 16 : 8;
18254
5/14
✓ Branch 0 taken 1400878 times.
✓ Branch 1 taken 72407 times.
✓ Branch 2 taken 333685 times.
✓ Branch 3 taken 1067193 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 333685 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
1473285 if(!ign_sv && dy < 0 && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
18255 return false;
18256
18257 1473285 bool nosolid = true;
18258
18259 1473285 bool ret = true;
18260
18261
3/4
✓ Branch 0 taken 756794 times.
✓ Branch 1 taken 716491 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 756794 times.
1473285 if(dx && !dy)
18262 {
18263
2/2
✓ Branch 0 taken 351756 times.
✓ Branch 1 taken 405038 times.
756794 if(dx < 0)
18264 {
18265 351756 zfix mx = bx+dx;
18266
2/2
✓ Branch 0 taken 351756 times.
✓ Branch 1 taken 235577 times.
587333 for(zfix ty = 0; by+ty < ry; ty += 8)
18267 {
18268
2/2
✓ Branch 0 taken 209107 times.
✓ Branch 1 taken 142649 times.
351756 if(scr_walkflag(mx, by+ty, left, kb, canladder))
18269 {
18270
2/2
✓ Branch 0 taken 26470 times.
✓ Branch 1 taken 116179 times.
142649 if (canladder) ret = false;
18271 else
18272 {
18273 116179 return false;
18274 }
18275 26470 }
18276 235577 }
18277
2/2
✓ Branch 0 taken 48785 times.
✓ Branch 1 taken 186792 times.
235577 if(scr_walkflag(mx, ry, left, kb, canladder))
18278 48785 return false;
18279
2/2
✓ Branch 0 taken 182756 times.
✓ Branch 1 taken 4036 times.
186792 if (!ret) return false;
18280
2/4
✓ Branch 0 taken 182756 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182756 times.
✗ Branch 3 not taken.
182756 if(nosolid && collide_object(bx+dx,by,-dx,hei,this))
18281 return false;
18282 182756 }
18283 else
18284 {
18285 405038 zfix mx = rx+dx;
18286 405038 int lx = mx-hit_width+1;
18287
2/2
✓ Branch 0 taken 405038 times.
✓ Branch 1 taken 272141 times.
677179 for(zfix ty = 0; by+ty < ry; ty += 8)
18288 {
18289
2/2
✓ Branch 0 taken 235800 times.
✓ Branch 1 taken 169238 times.
405038 if(scr_walkflag(mx, by+ty, right, kb, canladder))
18290 {
18291
2/2
✓ Branch 0 taken 36341 times.
✓ Branch 1 taken 132897 times.
169238 if (canladder) ret = false;
18292 else
18293 {
18294 132897 return false;
18295 }
18296 36341 }
18297 272141 }
18298
2/2
✓ Branch 0 taken 72956 times.
✓ Branch 1 taken 199185 times.
272141 if(scr_walkflag(mx, ry, right, kb, canladder))
18299 72956 return false;
18300
2/2
✓ Branch 0 taken 191739 times.
✓ Branch 1 taken 7446 times.
199185 if (!ret) return false;
18301
2/4
✓ Branch 0 taken 191739 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191739 times.
✗ Branch 3 not taken.
191739 if(nosolid && collide_object(bx+wid,by,dx,hei,this))
18302 return false;
18303 }
18304 374495 }
18305
2/4
✓ Branch 0 taken 716491 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 716491 times.
716491 else if(dy && !dx)
18306 {
18307
2/2
✓ Branch 0 taken 343209 times.
✓ Branch 1 taken 373282 times.
716491 if(dy < 0)
18308 {
18309 343209 zfix my = by+dy;
18310
2/2
✓ Branch 0 taken 595337 times.
✓ Branch 1 taken 232679 times.
828016 for(zfix tx = 0; bx+tx < rx; tx += 8)
18311 {
18312
2/2
✓ Branch 0 taken 365626 times.
✓ Branch 1 taken 229711 times.
595337 if(scr_walkflag(bx+tx, my, up, kb, canladder))
18313 {
18314
2/2
✓ Branch 0 taken 119181 times.
✓ Branch 1 taken 110530 times.
229711 if (canladder) ret = false;
18315 else
18316 {
18317 110530 return false;
18318 }
18319 119181 }
18320 484807 }
18321
2/2
✓ Branch 0 taken 76623 times.
✓ Branch 1 taken 156056 times.
232679 if(scr_walkflag(rx, my, up, kb, canladder))
18322 76623 return false;
18323
2/2
✓ Branch 0 taken 140293 times.
✓ Branch 1 taken 15763 times.
156056 if (!ret) return false;
18324
2/4
✓ Branch 0 taken 140293 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140293 times.
✗ Branch 3 not taken.
140293 if(nosolid && collide_object(bx,by+dy,wid,-dy,this))
18325 return false;
18326 140293 }
18327 else
18328 {
18329 373282 zfix my = ry+dy;
18330 373282 int ly = my-hit_height+1;
18331
2/2
✓ Branch 0 taken 612531 times.
✓ Branch 1 taken 211578 times.
824109 for(zfix tx = 0; bx+tx < rx; tx += 8)
18332 {
18333
2/2
✓ Branch 0 taken 401423 times.
✓ Branch 1 taken 211108 times.
612531 if(scr_walkflag(bx+tx, my, down, kb, canladder))
18334 {
18335
2/2
✓ Branch 0 taken 49404 times.
✓ Branch 1 taken 161704 times.
211108 if (canladder) ret = false;
18336 else
18337 {
18338 161704 return false;
18339 }
18340 49404 }
18341 450827 }
18342
2/2
✓ Branch 0 taken 60032 times.
✓ Branch 1 taken 151546 times.
211578 if(scr_walkflag(rx, my, down, kb, canladder))
18343 60032 return false;
18344
2/2
✓ Branch 0 taken 144737 times.
✓ Branch 1 taken 6809 times.
151546 if (!ret) return false;
18345
2/4
✓ Branch 0 taken 144737 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144737 times.
144737 if(nosolid && collide_object(bx,by+hei,wid,dy,this))
18346 return false;
18347 }
18348 285030 }
18349 else //! Untested, and currently unused.
18350 {
18351 return scr_canmove(dx, 0, kb, ign_sv) && scr_canmove(dy, 0, kb, ign_sv);
18352 }
18353 659525 return ret;
18354 1473285 }
18355 444360 bool handle_movestate(std::function<bool()> proc)
18356 {
18357 444360 zfix ox = Hero.x, oy = Hero.y;
18358 444360 auto oladderx = Hero.ladderx;
18359 444360 auto oladdery = Hero.laddery;
18360 444360 auto oladderdir = Hero.ladderdir;
18361 444360 auto oladderstart = Hero.ladderstart;
18362
18363 444360 bool ret = proc();
18364
18365 444360 Hero.x = ox;
18366 444360 Hero.y = oy;
18367 444360 Hero.ladderx = oladderx;
18368 444360 Hero.laddery = oladdery;
18369 444360 Hero.ladderdir = oladderdir;
18370 444360 Hero.ladderstart = oladderstart;
18371
18372 444360 return ret;
18373 }
18374
18375 70 zfix handle_movestate_zfix(std::function<zfix()> proc)
18376 {
18377 70 zfix ox = Hero.x, oy = Hero.y;
18378 70 auto oladderx = Hero.ladderx;
18379 70 auto oladdery = Hero.laddery;
18380 70 auto oladderdir = Hero.ladderdir;
18381 70 auto oladderstart = Hero.ladderstart;
18382
18383 70 zfix ret = proc();
18384
18385 70 Hero.x = ox;
18386 70 Hero.y = oy;
18387 70 Hero.ladderx = oladderx;
18388 70 Hero.laddery = oladdery;
18389 70 Hero.ladderdir = oladderdir;
18390 70 Hero.ladderstart = oladderstart;
18391
18392 70 return ret;
18393 }
18394
18395 53377 optional<zfix> HeroClass::get_solid_coord(zfix tx, zfix ty, byte dir, byte mdir, bool kb, zfix earlyterm, bool doladder)
18396 {
18397 53377 zfix tmp;
18398
4/5
✓ Branch 0 taken 4627 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9243 times.
✓ Branch 3 taken 21111 times.
✓ Branch 4 taken 18396 times.
53377 switch(dir)
18399 {
18400 default:
18401 case up:
18402
2/4
✓ Branch 0 taken 4627 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4627 times.
✗ Branch 3 not taken.
84684 tmp = binary_search_zfix(ty, earlyterm, [&](zfix ty, zfix& retval)
18403 {
18404 80057 int laddercheck = -1;
18405
2/2
✓ Branch 0 taken 40197 times.
✓ Branch 1 taken 39860 times.
80057 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18406 {
18407 40197 retval = ty;
18408 40197 return BSEARCH_CONTINUE_UP;
18409 }
18410
2/4
✓ Branch 0 taken 39860 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 39860 times.
39860 else if(doladder && laddercheck > 0)
18411 {
18412 retval = ty;
18413 return BSEARCH_CONTINUE_UP;
18414 }
18415 39860 else return BSEARCH_CONTINUE_DOWN;
18416
1/2
✓ Branch 0 taken 4627 times.
✗ Branch 1 not taken.
84684 }, -999);
18417
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 4222 times.
4627 if(tmp > -999)
18418 4222 tmp -= 15.9999_zf;
18419 4627 break;
18420 case down:
18421
2/4
✓ Branch 0 taken 9243 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9243 times.
✗ Branch 3 not taken.
171090 tmp = binary_search_zfix(ty, earlyterm, [&](zfix ty, zfix& retval)
18422 {
18423 161847 int laddercheck = -1;
18424
2/2
✓ Branch 0 taken 68573 times.
✓ Branch 1 taken 93274 times.
161847 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18425 {
18426 68573 retval = ty;
18427 68573 return BSEARCH_CONTINUE_DOWN;
18428 }
18429
2/4
✓ Branch 0 taken 93274 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93274 times.
93274 else if(doladder && laddercheck > 0)
18430 {
18431 retval = ty;
18432 return BSEARCH_CONTINUE_DOWN;
18433 }
18434 93274 else return BSEARCH_CONTINUE_UP;
18435
1/2
✓ Branch 0 taken 9243 times.
✗ Branch 1 not taken.
171090 }, -999);
18436
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 8919 times.
9243 if(tmp > -999)
18437 8919 tmp -= (bigHitbox?0:8);
18438 9243 break;
18439 case left:
18440
2/4
✓ Branch 0 taken 21111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21111 times.
✗ Branch 3 not taken.
395076 tmp = binary_search_zfix(tx, earlyterm, [&](zfix tx, zfix& retval)
18441 {
18442 373965 int laddercheck = -1;
18443
2/2
✓ Branch 0 taken 53414 times.
✓ Branch 1 taken 320551 times.
373965 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18444 {
18445 53414 retval = tx;
18446 53414 return BSEARCH_CONTINUE_UP;
18447 }
18448
2/4
✓ Branch 0 taken 320551 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 320551 times.
320551 else if(doladder && laddercheck > 0)
18449 {
18450 retval = tx;
18451 return BSEARCH_CONTINUE_UP;
18452 }
18453 320551 else return BSEARCH_CONTINUE_DOWN;
18454
1/2
✓ Branch 0 taken 21111 times.
✗ Branch 1 not taken.
395076 }, -999);
18455
2/2
✓ Branch 0 taken 15280 times.
✓ Branch 1 taken 5831 times.
21111 if(tmp > -999)
18456 5831 tmp -= 15.9999_zf;
18457 21111 break;
18458 case right:
18459
2/4
✓ Branch 0 taken 18396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18396 times.
✗ Branch 3 not taken.
345652 tmp = binary_search_zfix(tx, earlyterm, [&](zfix tx, zfix& retval)
18460 {
18461 327256 int laddercheck = -1;
18462
2/2
✓ Branch 0 taken 38219 times.
✓ Branch 1 taken 289037 times.
327256 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18463 {
18464 38219 retval = tx;
18465 38219 return BSEARCH_CONTINUE_DOWN;
18466 }
18467
2/4
✓ Branch 0 taken 289037 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 289037 times.
289037 else if(doladder && laddercheck > 0)
18468 {
18469 retval = tx;
18470 return BSEARCH_CONTINUE_DOWN;
18471 }
18472 289037 else return BSEARCH_CONTINUE_UP;
18473
1/2
✓ Branch 0 taken 18396 times.
✗ Branch 1 not taken.
345652 }, -999);
18474 18396 break;
18475 }
18476
2/2
✓ Branch 0 taken 29908 times.
✓ Branch 1 taken 23469 times.
53377 if(tmp > -999)
18477 {
18478 23469 zfix tx2(x), ty2(y);
18479 23469 zfix dx, dy;
18480
4/5
✓ Branch 0 taken 4222 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5831 times.
✓ Branch 3 taken 4497 times.
✓ Branch 4 taken 8919 times.
23469 switch(dir)
18481 {
18482 case left:
18483 5831 tx2 = tmp;
18484 5831 break;
18485 case right:
18486 4497 tx2 = tmp;
18487 4497 break;
18488 default:
18489 case up:
18490 4222 ty2 = tmp;
18491 4222 break;
18492 case down:
18493 8919 ty2 = tmp;
18494 8919 break;
18495 }
18496
4/5
✓ Branch 0 taken 4882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4110 times.
✓ Branch 3 taken 9031 times.
✓ Branch 4 taken 5446 times.
23469 switch(mdir)
18497 {
18498 case left:
18499 4110 dx = -0.0001_zf;
18500 4110 break;
18501 case right:
18502 9031 dx = 0.0001_zf;
18503 9031 break;
18504 default:
18505 case up:
18506 4882 dy = -0.0001_zf;
18507 4882 break;
18508 case down:
18509 5446 dy = 0.0001_zf;
18510 5446 break;
18511 }
18512 23469 zfix oldx(x), oldy(y);
18513 23469 x = tx2;
18514 23469 y = ty2;
18515 23469 int laddercheck = -1;
18516 23469 bool valid = scr_canmove(dx, dy, kb, true, &laddercheck);
18517
1/2
✓ Branch 0 taken 23469 times.
✗ Branch 1 not taken.
23469 if (laddercheck > 0) valid = true;
18518 23469 x = oldx;
18519 23469 y = oldy;
18520
2/2
✓ Branch 0 taken 23419 times.
✓ Branch 1 taken 50 times.
23469 if(valid)
18521 23419 return tmp;
18522 50 }
18523 29958 return std::nullopt;
18524 53377 }
18525
18526 721234 bool HeroClass::movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove, bool earlyret)
18527 {
18528 721234 bool ret = true;
18529 721234 int ladderstuff = -1;
18530
3/10
✓ Branch 0 taken 696765 times.
✓ Branch 1 taken 24469 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 696765 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
721234 bool sv = !ign_sv && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking;
18531
1/2
✓ Branch 0 taken 721234 times.
✗ Branch 1 not taken.
721234 if(sv)
18532 dy = 0;
18533
4/4
✓ Branch 0 taken 420622 times.
✓ Branch 1 taken 300612 times.
✓ Branch 2 taken 355105 times.
✓ Branch 3 taken 65517 times.
721234 if(dx && dy)
18534 65517 shove = false;
18535 721234 bool checkladder = dy < 0;
18536
18537 721234 const int scl = 2;
18538
4/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 721290 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 721234 times.
721304 while(abs(dx) > scl || abs(dy) > scl)
18539 {
18540
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 56 times.
70 if(abs(dx) > abs(dy))
18541 {
18542 14 int32_t tdx = dx.sign() * scl;
18543
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(movexy(tdx, 0, kb, ign_sv, shove, earlyret))
18544 14 dx -= tdx;
18545 else
18546 {
18547 if(earlyret) return false;
18548 dx = tdx;
18549 ret = false;
18550 }
18551 14 }
18552 else
18553 {
18554 56 int32_t tdy = dy.sign() * scl;
18555
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(movexy(0, tdy, kb, ign_sv, shove, earlyret))
18556 56 dy -= tdy;
18557 else
18558 {
18559 if(earlyret) return false;
18560 dy = tdy;
18561 ret = false;
18562 }
18563 }
18564 }
18565
18566
10/12
✓ Branch 0 taken 276734 times.
✓ Branch 1 taken 444500 times.
✓ Branch 2 taken 23182 times.
✓ Branch 3 taken 253552 times.
✓ Branch 4 taken 23182 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 556 times.
✓ Branch 7 taken 22626 times.
✓ Branch 8 taken 22526 times.
✓ Branch 9 taken 100 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 22526 times.
721234 bool skipdmg = earlyret || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS));
18567
2/2
✓ Branch 0 taken 300612 times.
✓ Branch 1 taken 420622 times.
721234 if(dx)
18568 {
18569
2/2
✓ Branch 0 taken 350219 times.
✓ Branch 1 taken 70403 times.
420622 if(scr_canmove(dx, 0, kb, ign_sv, &ladderstuff))
18570 {
18571
1/2
✓ Branch 0 taken 350219 times.
✗ Branch 1 not taken.
350219 if (ladderstuff == 1)
18572 {
18573 zfix tx = (dx < 0 ? (x+dx) : (x+8+dx));
18574 zfix tx2 = (dx < 0 ? 15 : 0);
18575 zfix tx3 = (dx < 0 ? -8 : 8);
18576 ladderx = tx.getInt()&0xF8;
18577 laddery = y.getTrunc();
18578 if (((iswaterex(MAPCOMBO(ladderx+tx2,y+9), currmap, currscr, -1, ladderx+tx2,y+9) != 0) || getpitfall(ladderx+tx2,y+9))
18579 && ((iswaterex(MAPCOMBO(ladderx+tx2,y+15), currmap, currscr, -1, ladderx+tx2,y+15) != 0) || getpitfall(ladderx+tx2,y+15)))
18580 {
18581 ladderdir = left;
18582 ladderstart = dir;
18583 }
18584 else if (((iswaterex(MAPCOMBO(ladderx+tx2+tx3,y+9), currmap, currscr, -1, ladderx+tx2+tx3,y+9) != 0) || getpitfall(ladderx+tx2+tx3,y+9))
18585 && ((iswaterex(MAPCOMBO(ladderx+tx2+tx3,y+15), currmap, currscr, -1, ladderx+tx2+tx3,y+15) != 0) || getpitfall(ladderx+tx2+tx3,y+15)))
18586 {
18587 ladderx = (tx.getInt()+tx3.getInt())&0xF8;
18588 ladderdir = left;
18589 ladderstart = dir;
18590 }
18591 else
18592 {
18593 ladderx = 0;
18594 laddery = 0;
18595 }
18596 }
18597
1/2
✓ Branch 0 taken 350219 times.
✗ Branch 1 not taken.
350219 if (ladderstuff > 0) ladderstuff = 0;
18598 350219 x += dx;
18599 350219 }
18600 else
18601 {
18602 70403 bool stopped = true;
18603 70403 bool shoved = false;
18604
2/2
✓ Branch 0 taken 10934 times.
✓ Branch 1 taken 59469 times.
70403 if(shove)
18605 {
18606
2/2
✓ Branch 0 taken 24467 times.
✓ Branch 1 taken 35002 times.
59469 zfix tx = (dx < 0 ? (x-4) : (x+20));
18607 59469 int v=bigHitbox?0:8;
18608 59469 zfix ly = y+v;
18609 59469 zfix ry = y+15.9999_zf;
18610 59469 zfix ly2 = y+v+6;
18611 59469 zfix ry2 = y+9.9999_zf;
18612 59469 auto mdir = GET_XDIR(dx);
18613 59469 int laddershove = -1;
18614 59469 int ladderhit = 0;
18615 59469 bool onladder = (ladderx + laddery);
18616 59469 bool hit_top = scr_walkflag(tx,ly,mdir,false, &laddershove);
18617
1/2
✓ Branch 0 taken 59469 times.
✗ Branch 1 not taken.
59469 if (laddershove > 0)
18618 {
18619 hit_top = false;
18620 ladderhit += 1;
18621 }
18622 59469 laddershove = -1;
18623 59469 bool hit_bottom = scr_walkflag(tx,ry,mdir,false, &laddershove);
18624
1/2
✓ Branch 0 taken 59469 times.
✗ Branch 1 not taken.
59469 if (laddershove > 0)
18625 {
18626 hit_bottom = false;
18627 ladderhit += 2;
18628 }
18629 59469 laddershove = -1;
18630 59469 bool hit_top2 = scr_walkflag(tx,ly2,mdir,false);
18631 59469 bool hit_bottom2 = scr_walkflag(tx,ry2,mdir,false);
18632
3/4
✓ Branch 0 taken 4744 times.
✓ Branch 1 taken 54725 times.
✓ Branch 2 taken 4744 times.
✗ Branch 3 not taken.
59469 if (!hit_top && ladderhit == 2)
18633 {
18634 hit_bottom = true;
18635 }
18636
3/4
✓ Branch 0 taken 9360 times.
✓ Branch 1 taken 50109 times.
✓ Branch 2 taken 9360 times.
✗ Branch 3 not taken.
59469 if (!hit_bottom && ladderhit == 1)
18637 {
18638 hit_top = true;
18639 }
18640
2/2
✓ Branch 0 taken 45599 times.
✓ Branch 1 taken 13870 times.
59469 if(hit_top!=hit_bottom)
18641 {
18642
2/2
✓ Branch 0 taken 4627 times.
✓ Branch 1 taken 9243 times.
13870 if(hit_bottom) //shove up
18643 {
18644
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4627 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4627 if (onladder && (ladderdir == left || ladderdir == right) && !hit_bottom2)
18645 {
18646 y -= 1_zf;
18647 shoved = true;
18648 }
18649
4/6
✓ Branch 0 taken 4613 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4627 times.
4627 else if(skipdmg || !checkdamagecombos(tx,get_qr(qr_SENSITIVE_SOLID_DAMAGE)?int32_t(y+15):(v+bigHitbox?11:4)))
18650 {
18651
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 4218 times.
4627 if(optional<zfix> ty = get_solid_coord(tx,ry,up,mdir,false,ry-shove_offset, (ladderhit != 2)))
18652 {
18653
2/2
✓ Branch 0 taken 1023 times.
✓ Branch 1 taken 3195 times.
4218 zfix dy = zc_max(-1_zf,*ty-y);
18654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4218 times.
4218 if((shoved = dy))
18655 4218 movexy(0, dy, kb, true, false, false);
18656 4218 }
18657 4627 }
18658 4627 }
18659 else //shove down
18660 {
18661
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9243 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9243 if (onladder && (ladderdir == left || ladderdir == right) && !hit_top2)
18662 {
18663 y += 1_zf;
18664 shoved = true;
18665 }
18666
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9242 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
9243 else if(skipdmg || !checkdamagecombos(tx,v+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
18667 {
18668
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 8919 times.
9243 if(optional<zfix> ty = get_solid_coord(tx,ly,down,mdir,false,ly+shove_offset, (ladderhit != 1)))
18669 {
18670
2/2
✓ Branch 0 taken 8286 times.
✓ Branch 1 taken 633 times.
8919 zfix dy = zc_min(1_zf,*ty-y);
18671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8919 times.
8919 if((shoved = dy))
18672 8919 movexy(0, dy, kb, true, false, false);
18673 8919 }
18674 9243 }
18675 }
18676
18677
4/4
✓ Branch 0 taken 13137 times.
✓ Branch 1 taken 733 times.
✓ Branch 2 taken 11366 times.
✓ Branch 3 taken 1771 times.
13870 if(shoved && scr_canmove(dx, 0, kb, ign_sv))
18678 {
18679 1771 x += dx;
18680 1771 stopped = false;
18681 1771 }
18682 13870 }
18683 59469 }
18684
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 68632 times.
70403 if(stopped)
18685 {
18686
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 68632 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
68632 if (ladderstuff > 0 && !shoved)
18687 {
18688 zfix tx = (dx < 0 ? (x-12) : (x+20));
18689 ladderx = tx.getInt()&0xF8;
18690 laddery = y.getTrunc();
18691 ladderdir = left;
18692 ladderstart = dir;
18693 x += dx;
18694 ladderstuff = 0;
18695 }
18696
2/2
✓ Branch 0 taken 48997 times.
✓ Branch 1 taken 19635 times.
68632 else if(earlyret)
18697 {
18698 48997 ret = false;
18699 48997 }
18700 else
18701 {
18702 19635 ret = false;
18703 19635 int xsign = dx.sign();
18704
2/2
✓ Branch 0 taken 1854 times.
✓ Branch 1 taken 17781 times.
19635 if(abs(dx) > 1)
18705 {
18706
2/2
✓ Branch 0 taken 465 times.
✓ Branch 1 taken 17781 times.
18246 while(scr_canmove(xsign, 0, kb, ign_sv))
18707 {
18708 465 x += xsign;
18709 465 dx -= xsign;
18710 }
18711 17781 }
18712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19635 times.
19635 if(dx)
18713 {
18714 19635 dx.doDecBound(0,-9999, 0,9999);
18715
3/6
✓ Branch 0 taken 19635 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19635 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19635 times.
✗ Branch 5 not taken.
311269 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
18716
2/2
✓ Branch 0 taken 8889 times.
✓ Branch 1 taken 282745 times.
291634 if(scr_canmove(val, 0, kb, ign_sv))
18717 {
18718 8889 retval = val;
18719 8889 return BSEARCH_CONTINUE_AWAY0;
18720 }
18721 282745 else return BSEARCH_CONTINUE_TOWARD0;
18722 291634 });
18723 19635 x += dx;
18724 19635 }
18725 }
18726 68632 }
18727 }
18728 420622 }
18729 721234 ladderstuff = -1;
18730
2/2
✓ Branch 0 taken 356063 times.
✓ Branch 1 taken 365171 times.
721234 if(dy)
18731 {
18732
2/2
✓ Branch 0 taken 260923 times.
✓ Branch 1 taken 104248 times.
365171 if(scr_canmove(0, dy, kb, ign_sv, &ladderstuff))
18733 {
18734
1/2
✓ Branch 0 taken 260923 times.
✗ Branch 1 not taken.
260923 if (ladderstuff == 1)
18735 {
18736 zfix ty = (dy < 0 ? (y+(bigHitbox?0:8)+dy) : (y+8+dy));
18737 zfix ty2 = (dy < 0 ? 15 : 0);
18738 zfix ty3 = (dy < 0 ? -8 : 8);
18739
18740 ladderx = x.getTrunc();
18741 laddery = ty.getInt()&0xF8;
18742 if (((iswaterex(MAPCOMBO(x+4,laddery+ty2), currmap, currscr, -1, x+4,laddery+ty2) != 0) || getpitfall(x+4,laddery+ty2))
18743 && ((iswaterex(MAPCOMBO(x+11,laddery+ty2), currmap, currscr, -1, x+11,laddery+ty2) != 0) || getpitfall(x+11,laddery+ty2)))
18744 {
18745 ladderdir = up;
18746 ladderstart = dir;
18747 }
18748 else if (((iswaterex(MAPCOMBO(x+4,laddery+ty2+ty3), currmap, currscr, -1, x+4,laddery+ty2+ty3) != 0) || getpitfall(x+4,laddery+ty2+ty3))
18749 && ((iswaterex(MAPCOMBO(x+11,laddery+ty2+ty3), currmap, currscr, -1, x+11,laddery+ty2+ty3) != 0) || getpitfall(x+11,laddery+ty2+ty3)))
18750 {
18751 laddery = (ty.getInt() + ty3.getInt())&0xF8;
18752 ladderdir = up;
18753 ladderstart = dir;
18754 }
18755 else
18756 {
18757 ladderx = 0;
18758 laddery = 0;
18759 }
18760 }
18761
1/2
✓ Branch 0 taken 260923 times.
✗ Branch 1 not taken.
260923 if (ladderstuff > 0) ladderstuff = 0;
18762 260923 y += dy;
18763 260923 }
18764 else
18765 {
18766 104248 bool stopped = true;
18767 104248 bool shoved = false;
18768
2/2
✓ Branch 0 taken 12092 times.
✓ Branch 1 taken 92156 times.
104248 if(shove)
18769 {
18770
2/2
✓ Branch 0 taken 66475 times.
✓ Branch 1 taken 25681 times.
92156 zfix ty = (dy < 0 ? (y+(bigHitbox?0:8)-4) : (y+20));
18771 92156 zfix lx = x;
18772 92156 zfix rx = x+15.9999_zf;
18773 92156 zfix lx2 = x+6;
18774 92156 zfix rx2 = x+9.9999_zf;
18775 92156 auto mdir = GET_YDIR(dy);
18776 92156 int laddershove = -1;
18777 92156 int ladderhit = 0;
18778 92156 bool onladder = (ladderx + laddery);
18779 92156 bool hit_left = scr_walkflag(lx,ty,mdir,false, &laddershove);
18780
1/2
✓ Branch 0 taken 92156 times.
✗ Branch 1 not taken.
92156 if (laddershove > 0)
18781 {
18782 hit_left = false;
18783 ladderhit += 1;
18784 }
18785 92156 laddershove = -1;
18786 92156 bool hit_right = scr_walkflag(rx,ty,mdir,false, &laddershove);
18787
1/2
✓ Branch 0 taken 92156 times.
✗ Branch 1 not taken.
92156 if (laddershove > 0)
18788 {
18789 hit_right = false;
18790 ladderhit += 2;
18791 }
18792 92156 bool hit_left2 = scr_walkflag(lx2,ty,mdir,false);
18793 92156 bool hit_right2 = scr_walkflag(rx2,ty,mdir,false);
18794 92156 laddershove = -1;
18795
3/4
✓ Branch 0 taken 21285 times.
✓ Branch 1 taken 70871 times.
✓ Branch 2 taken 21285 times.
✗ Branch 3 not taken.
92156 if (!hit_left && ladderhit == 2)
18796 {
18797 hit_right = true;
18798 }
18799
3/4
✓ Branch 0 taken 18570 times.
✓ Branch 1 taken 73586 times.
✓ Branch 2 taken 18570 times.
✗ Branch 3 not taken.
92156 if (!hit_right && ladderhit == 1)
18800 {
18801 hit_left = true;
18802 }
18803
2/2
✓ Branch 0 taken 52649 times.
✓ Branch 1 taken 39507 times.
92156 if(hit_left!=hit_right)
18804 {
18805
2/2
✓ Branch 0 taken 21111 times.
✓ Branch 1 taken 18396 times.
39507 if(hit_right) //shove left
18806 {
18807
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21111 if (onladder && ladderdir <= down && !hit_right2)
18808 {
18809 x -= 1_zf;
18810 shoved = true;
18811 }
18812
3/4
✓ Branch 0 taken 21106 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21111 times.
21111 else if(skipdmg || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),ty))
18813 {
18814
2/2
✓ Branch 0 taken 15280 times.
✓ Branch 1 taken 5831 times.
21111 if(optional<zfix> tx = get_solid_coord(rx,ty,left,mdir,false,rx-shove_offset, (ladderhit != 2)))
18815 {
18816
2/2
✓ Branch 0 taken 4391 times.
✓ Branch 1 taken 1440 times.
5831 zfix dx = zc_max(-1_zf,*tx-x);
18817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5831 times.
5831 if((shoved = dx))
18818 5831 movexy(dx, 0, kb, true, false, false);
18819 5831 }
18820 21111 }
18821 21111 }
18822 else //shove right
18823 {
18824
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18396 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18396 if (onladder && ladderdir <= down && !hit_left2)
18825 {
18826 x += 1_zf;
18827 shoved = true;
18828 }
18829
3/4
✓ Branch 0 taken 18393 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18396 times.
18396 else if(skipdmg || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),ty))
18830 {
18831
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 4451 times.
18396 if(optional<zfix> tx = get_solid_coord(lx,ty,right,mdir,false,lx+shove_offset, (ladderhit != 1)))
18832 {
18833
2/2
✓ Branch 0 taken 1671 times.
✓ Branch 1 taken 2780 times.
4451 zfix dx = zc_min(1_zf,*tx-x);
18834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4451 times.
4451 if((shoved = dx))
18835 4451 movexy(dx, 0, kb, true, false, false);
18836 4451 }
18837 18396 }
18838 }
18839
18840
4/4
✓ Branch 0 taken 10282 times.
✓ Branch 1 taken 29225 times.
✓ Branch 2 taken 6903 times.
✓ Branch 3 taken 3379 times.
39507 if(shoved && scr_canmove(0, dy, kb, ign_sv))
18841 {
18842 3379 y += dy;
18843 3379 stopped = false;
18844 3379 }
18845 39507 }
18846 92156 }
18847
2/2
✓ Branch 0 taken 3379 times.
✓ Branch 1 taken 100869 times.
104248 if(stopped)
18848 {
18849
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 100869 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
100869 if (ladderstuff > 0 && !shoved)
18850 {
18851 zfix ty = (dy < 0 ? (y-(bigHitbox?12:4)) : (y+20));
18852 ladderx = x.getTrunc();
18853 laddery = ty.getInt()&0xF8;
18854 ladderdir = up;
18855 ladderstart = dir;
18856 y += dy;
18857 ladderstuff = 0;
18858 }
18859 else
18860 {
18861
2/2
✓ Branch 0 taken 79867 times.
✓ Branch 1 taken 21002 times.
100869 if(earlyret) return false;
18862 21002 ret = false;
18863 21002 int ysign = dy.sign();
18864
2/2
✓ Branch 0 taken 2784 times.
✓ Branch 1 taken 18218 times.
21002 if(abs(dy) > 1)
18865 {
18866
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 18218 times.
18557 while(scr_canmove(0, ysign, kb, ign_sv))
18867 {
18868 339 y += ysign;
18869 339 dy -= ysign;
18870 }
18871 18218 }
18872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21002 times.
21002 if(dy)
18873 {
18874 21002 dy.doDecBound(0,-9999, 0,9999);
18875
3/6
✓ Branch 0 taken 21002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21002 times.
✗ Branch 5 not taken.
333099 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
18876
2/2
✓ Branch 0 taken 10051 times.
✓ Branch 1 taken 302046 times.
312097 if(scr_canmove(0, val, kb, ign_sv))
18877 {
18878 10051 retval = val;
18879 10051 return BSEARCH_CONTINUE_AWAY0;
18880 }
18881 302046 else return BSEARCH_CONTINUE_TOWARD0;
18882 312097 });
18883 21002 y += dy;
18884 21002 }
18885 }
18886 21002 }
18887 }
18888 285304 }
18889
18890
2/2
✓ Branch 0 taken 364633 times.
✓ Branch 1 taken 276734 times.
641367 if(earlyret)
18891 364633 return ret;
18892
5/10
✓ Branch 0 taken 64233 times.
✓ Branch 1 taken 212501 times.
✓ Branch 2 taken 60045 times.
✓ Branch 3 taken 4188 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60045 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
276734 if(dy < 0 && !ign_sv && sideview_mode() && IsSideSwim() && checkladder)
18893 {
18894 if(!iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)-2), currmap, currscr, -1, x, y+(bigHitbox?0:8) - 2, true, false)
18895 && !canSideviewLadderRemote(x, y-4) && scr_canmove(0, -2, kb, true) && (y+(bigHitbox?0:8) - 4) > 0)
18896 {
18897 if (game->get_sideswim_jump() != 0)
18898 {
18899 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
18900 sfx(WAV_ZN1SPLASH,(int32_t)x);
18901 hopclk = 0;
18902 if (charging || spins) action = attacking;
18903 else action = none;
18904 }
18905 else
18906 {
18907 movexy(0,-1*dy,false,false,false);
18908 }
18909 }
18910 }
18911 276734 return ret;
18912 721234 }
18913 3596 bool HeroClass::can_movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove)
18914 {
18915
1/2
✓ Branch 0 taken 3596 times.
✗ Branch 1 not taken.
7192 return handle_movestate([&]()
18916 {
18917 3596 return movexy(dx,dy,kb,ign_sv,shove,true);
18918 });
18919 }
18920 bool HeroClass::moveAtAngle(zfix degrees, zfix px, bool kb, bool ign_sv, bool shove, bool earlyret)
18921 {
18922 double v = degrees.getFloat() * PI / 180.0;
18923 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
18924 return movexy(dx, dy, kb, ign_sv, shove, earlyret);
18925 }
18926 bool HeroClass::can_moveAtAngle(zfix degrees, zfix px, bool kb, bool ign_sv, bool shove)
18927 {
18928 return handle_movestate([&]()
18929 {
18930 return moveAtAngle(degrees,px,kb,ign_sv,shove,true);
18931 });
18932 }
18933 440764 bool HeroClass::moveDir(int dir, zfix px, bool kb, bool ign_sv, bool shove, bool earlyret)
18934 {
18935
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 440762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
440764 static const zfix diagrate = zslongToFix(7071);
18936
6/13
✓ Branch 0 taken 440764 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 440764 times.
✓ Branch 4 taken 128017 times.
✓ Branch 5 taken 84306 times.
✓ Branch 6 taken 110138 times.
✓ Branch 7 taken 118303 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
440764 switch(NORMAL_DIR(dir))
18937 {
18938 case up:
18939 128017 return movexy(0, -px, kb, ign_sv, shove, earlyret);
18940 case down:
18941 84306 return movexy(0, px, kb, ign_sv, shove, earlyret);
18942 case left:
18943 110138 return movexy(-px, 0, kb, ign_sv, shove, earlyret);
18944 case right:
18945 118303 return movexy(px, 0, kb, ign_sv, shove, earlyret);
18946 case r_up:
18947 return movexy(px*diagrate, -px*diagrate, kb, ign_sv, shove, earlyret);
18948 case r_down:
18949 return movexy(px*diagrate, px*diagrate, kb, ign_sv, shove, earlyret);
18950 case l_up:
18951 return movexy(-px*diagrate, -px*diagrate, kb, ign_sv, shove, earlyret);
18952 case l_down:
18953 return movexy(-px*diagrate, px*diagrate, kb, ign_sv, shove, earlyret);
18954 }
18955 return false;
18956 440764 }
18957 440764 bool HeroClass::can_moveDir(int dir, zfix px, bool kb, bool ign_sv, bool shove)
18958 {
18959
1/2
✓ Branch 0 taken 440764 times.
✗ Branch 1 not taken.
881528 return handle_movestate([&]()
18960 {
18961 440764 return moveDir(dir,px,kb,ign_sv,shove,true);
18962 });
18963 }
18964
18965
18966 391624 bool HeroClass::premove()
18967 {
18968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391624 times.
391624 if(lstunclock) return false;
18969
3/4
✓ Branch 0 taken 3217 times.
✓ Branch 1 taken 388407 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3217 times.
391624 if(is_conveyor_stunned) return (convey_forcex || convey_forcey);
18970 388407 int32_t xoff=x.getInt()&7;
18971 388407 int32_t yoff=y.getInt()&7;
18972
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 388407 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
388407 if(NO_GRIDLOCK)
18973 {
18974 388407 xoff = 0;
18975 388407 yoff = 0;
18976 388407 }
18977 388407 int32_t push=pushing;
18978 388407 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
18979 388407 int32_t flippers_id = current_item_id(itype_flippers);
18980 388407 itemdata const& itm = itemsbuf[flippers_id];
18981 388407 byte intbtn = byte(itm.misc3&0xFF);
18982 388407 bool dive_pressed = getIntBtnInput(intbtn, true, true, false, false, true);
18983 388407 bool eatdive = false;
18984
2/2
✓ Branch 0 taken 411 times.
✓ Branch 1 taken 387996 times.
388407 if(diveclk>0)
18985 {
18986
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 411 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
411 if (isSideViewHero() && get_qr(qr_SIDESWIM)) diveclk = 0;
18987 411 --diveclk;
18988
4/8
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 326 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 326 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
411 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag2 && dive_pressed) //Cancellable Diving -V
18989 {
18990 diveclk = itemsbuf[flippers_id].misc2;
18991 eatdive = true;
18992 }
18993 411 }
18994
4/4
✓ Branch 0 taken 6251 times.
✓ Branch 1 taken 381745 times.
✓ Branch 2 taken 6240 times.
✓ Branch 3 taken 11 times.
387996 else if(action == swimming && dive_pressed)
18995 {
18996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag1);
18997 11 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
18998
18999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(global_diving==screen_diving)
19000 {
19001
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
19002 11 eatdive = true;
19003 11 }
19004 11 }
19005
2/2
✓ Branch 0 taken 388396 times.
✓ Branch 1 taken 11 times.
388407 if(eatdive)
19006 11 getIntBtnInput(intbtn, true, true, false, false, false);
19007
19008
1/2
✓ Branch 0 taken 388407 times.
✗ Branch 1 not taken.
388407 if(action==rafting)
19009 {
19010 do_rafting();
19011
19012 if(action==rafting)
19013 {
19014 return false;
19015 }
19016
19017
19018 set_respawn_point();
19019 trySideviewLadder();
19020 }
19021
19022 388407 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
19023 388407 int32_t btnwpn = -1;
19024
19025 //&0xFFF removes the "bow & arrows" bitmask
19026 //The Quick Sword is allowed to interrupt attacks.
19027
4/4
✓ Branch 0 taken 377729 times.
✓ Branch 1 taken 10678 times.
✓ Branch 2 taken 256212 times.
✓ Branch 3 taken 121517 times.
388407 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
19028
7/8
✓ Branch 0 taken 354285 times.
✓ Branch 1 taken 34122 times.
✓ Branch 2 taken 354220 times.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 5547 times.
✓ Branch 5 taken 28640 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 34187 times.
388407 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & item_flag5)))
19029 {
19030
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 354046 times.
354220 if(DrunkrBbtn())
19031 {
19032 174 btnwpn=getItemFamily(itemsbuf,Bwpn);
19033
1/2
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
174 dowpn = NEG_OR_MASK(Bwpn,0xFFF);
19034 174 directWpn = directItemB;
19035 174 }
19036
2/2
✓ Branch 0 taken 2097 times.
✓ Branch 1 taken 351949 times.
354046 else if(DrunkrAbtn())
19037 {
19038 2097 btnwpn=getItemFamily(itemsbuf,Awpn);
19039
1/2
✓ Branch 0 taken 2097 times.
✗ Branch 1 not taken.
2097 dowpn = NEG_OR_MASK(Awpn,0xFFF);
19040 2097 directWpn = directItemA;
19041 2097 }
19042
3/4
✓ Branch 0 taken 351949 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351826 times.
✓ Branch 3 taken 123 times.
351949 else if(get_qr(qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
19043 {
19044 123 btnwpn=getItemFamily(itemsbuf,Xwpn);
19045
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 dowpn = NEG_OR_MASK(Xwpn,0xFFF);
19046 123 directWpn = directItemX;
19047 123 }
19048
3/4
✓ Branch 0 taken 351826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351713 times.
✓ Branch 3 taken 113 times.
351826 else if(get_qr(qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
19049 {
19050 113 btnwpn=getItemFamily(itemsbuf,Ywpn);
19051
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 dowpn = NEG_OR_MASK(Ywpn,0xFFF);
19052 113 directWpn = directItemY;
19053 113 }
19054
19055
1/2
✓ Branch 0 taken 354220 times.
✗ Branch 1 not taken.
354220 if(directWpn >= MAXITEMS) directWpn = -1;
19056
19057 // The Quick Sword only allows repeated sword or wand swings.
19058
3/8
✓ Branch 0 taken 354220 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 354220 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 354220 times.
354220 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
19059 btnwpn=-1;
19060 354220 }
19061
19062
2/2
✓ Branch 0 taken 132197 times.
✓ Branch 1 taken 256210 times.
388407 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
19063
10/12
✓ Branch 0 taken 373805 times.
✓ Branch 1 taken 14602 times.
✓ Branch 2 taken 371156 times.
✓ Branch 3 taken 2649 times.
✓ Branch 4 taken 244736 times.
✓ Branch 5 taken 126420 times.
✓ Branch 6 taken 244736 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2097 times.
✓ Branch 9 taken 242639 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2097 times.
388407 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
19064 {
19065
1/2
✓ Branch 0 taken 2097 times.
✗ Branch 1 not taken.
2097 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
19066
2/6
✓ Branch 0 taken 2097 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2097 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2097 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & item_flag6)))
19067 {
19068
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2097 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
19069 {
19070 paymagiccost(attackid,true);
19071 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
19072 }
19073 2097 SetAttack();
19074 2097 attack=wSword;
19075
19076 2097 attackclk=0;
19077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2097 times.
2097 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
19078
19079
2/10
✓ Branch 0 taken 2097 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2097 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2097 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
19080 {
19081 if(!checkmagiccost(dowpn))
19082 {
19083 item_error();
19084 }
19085 else
19086 {
19087 //clear the item script stack for a new script
19088 int i = dowpn;
19089 FFCore.reset_script_engine_data(ScriptType::Item, i);
19090 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
19091 did_scripta=true;
19092 }
19093 }
19094 2097 }
19095 else
19096 {
19097 item_error();
19098 }
19099 2097 }
19100 else
19101 {
19102 386310 did_scripta=false;
19103 }
19104
19105
6/10
✓ Branch 0 taken 381745 times.
✓ Branch 1 taken 6662 times.
✓ Branch 2 taken 381745 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 381745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 381745 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 381745 times.
388407 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
19106 {
19107
3/4
✓ Branch 0 taken 67380 times.
✓ Branch 1 taken 314365 times.
✓ Branch 2 taken 67380 times.
✗ Branch 3 not taken.
381745 if(DrunkUp() && canSideviewLadder())
19108 {
19109 setOnSideviewLadder(true);
19110 }
19111
3/4
✓ Branch 0 taken 71299 times.
✓ Branch 1 taken 310446 times.
✓ Branch 2 taken 71299 times.
✗ Branch 3 not taken.
381745 else if(DrunkDown() && canSideviewLadder(true))
19112 {
19113 y+=1;
19114 setOnSideviewLadder(true);
19115 }
19116 381745 }
19117
19118 388407 int32_t wx=x;
19119 388407 int32_t wy=y;
19120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388407 times.
388407 if(conv_forcedir > -1) dir = conv_forcedir;
19121
3/6
✓ Branch 0 taken 282848 times.
✓ Branch 1 taken 105559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 388407 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
388407 else if((action==none || action==walking) && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
19122 {
19123 if((xoff==0)||diagonalMovement)
19124 {
19125 if(DrunkUp()) dir=up;
19126 if(DrunkDown()) dir=down;
19127 }
19128
19129 if((yoff==0)||diagonalMovement)
19130 {
19131 if(DrunkLeft()) dir=left;
19132 if(DrunkRight()) dir=right;
19133 }
19134 }
19135
19136
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 78067 times.
✓ Branch 2 taken 85319 times.
✓ Branch 3 taken 113642 times.
✓ Branch 4 taken 111379 times.
388407 switch(dir)
19137 {
19138 case up:
19139 78067 wy-=16;
19140 78067 break;
19141
19142 case down:
19143 85319 wy+=16;
19144 85319 break;
19145
19146 case left:
19147 113642 wx-=16;
19148 113642 break;
19149
19150 case right:
19151 111379 wx+=16;
19152 111379 break;
19153 }
19154
19155 388407 do_lens();
19156
19157 388407 bool no_jinx = true;
19158
6/8
✓ Branch 0 taken 373805 times.
✓ Branch 1 taken 14602 times.
✓ Branch 2 taken 406 times.
✓ Branch 3 taken 373399 times.
✓ Branch 4 taken 406 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 406 times.
388407 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
19159 {
19160 406 bool paidmagic = false;
19161
1/2
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
406 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
19162
6/10
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 347 times.
✓ Branch 3 taken 59 times.
✓ Branch 4 taken 59 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 59 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 59 times.
406 if(!liftonly && btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
19163 {
19164
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
19165 59 no_jinx = checkitem_jinx(attackid);
19166
3/8
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
59 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & item_flag6)) || checkmagiccost(attackid)))
19167 {
19168
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
19169 paymagiccost(attackid,true);
19170 misc_internal_hero_flags |= LF_PAID_WAND_COST;
19171 }
19172 59 SetAttack();
19173 59 attack=wWand;
19174 59 attackclk=0;
19175 59 }
19176 else
19177 {
19178 item_error();
19179 }
19180 59 }
19181
2/8
✓ Branch 0 taken 347 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 347 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
347 else if(!liftonly && (btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
19182 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
19183 {
19184 no_jinx = checkitem_jinx(dowpn);
19185 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
19186 {
19187 item_error();
19188 }
19189 else
19190 {
19191 paymagiccost(dowpn);
19192 paidmagic = true;
19193 SetAttack();
19194 attack=wHammer;
19195 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
19196 attackclk=0;
19197 }
19198 }
19199
5/8
✓ Branch 0 taken 347 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 47 times.
394 else if(!liftonly && (btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
19200
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
47 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
19201 {
19202 //checkbunny handled where magic cost is paid
19203
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
19204 47 no_jinx = checkitem_jinx(attackid);
19205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(no_jinx)
19206 {
19207 47 SetAttack();
19208 47 attack=wFire;
19209 47 attackclk=0;
19210 47 }
19211 47 }
19212
2/8
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 300 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
300 else if(!liftonly && (btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
19213 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
19214 {
19215 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
19216 no_jinx = checkitem_jinx(attackid);
19217 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & item_flag6)) || checkmagiccost(attackid)))
19218 {
19219 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
19220 paymagiccost(attackid,true);
19221 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
19222 }
19223 SetAttack();
19224 attack=wCByrna;
19225 attackclk=0;
19226 }
19227 else
19228 {
19229 item_error();
19230 }
19231 }
19232
5/8
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 294 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6 times.
306 else if(!liftonly && (btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
19233
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
6 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
19234 {
19235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
19236 6 no_jinx = checkitem_jinx(attackid);
19237
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
6 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
19238 {
19239 6 paymagiccost(attackid);
19240 6 SetAttack();
19241 6 attack = wBugNet;
19242 6 attackclk = 0;
19243 6 sfx(itemsbuf[attackid].usesound);
19244 6 }
19245 else
19246 {
19247 item_error();
19248 }
19249 6 }
19250 else
19251 {
19252
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
19253 294 no_jinx = checkitem_jinx(itmid);
19254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 if(no_jinx)
19255 {
19256 294 paidmagic = startwpn(itmid);
19257
19258
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 if(paidmagic)
19259 {
19260
5/10
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 294 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 294 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 294 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 294 times.
294 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
19261 {
19262 ;
19263 }
19264 else
19265 {
19266 294 SetAttack();
19267 294 attackclk=0;
19268 294 attack=none;
19269
19270
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 172 times.
294 if(btnwpn==itype_brang)
19271 {
19272 122 attack=wBrang;
19273 122 }
19274 }
19275 294 }
19276 else
19277 {
19278 // Weapon not started: directWpn should be reset to prev. value.
19279 directWpn = olddirectwpn;
19280 }
19281 294 }
19282 }
19283
19284
3/12
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 406 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 406 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
406 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
19285 {
19286 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
19287 {
19288 item_error();
19289 }
19290 else
19291 {
19292 // Only charge for magic if item's magic cost wasn't already charged
19293 // for the item's main use.
19294 if(!paidmagic && attack!=wWand)
19295 paymagiccost(dowpn);
19296 //clear the item script stack for a new script
19297 int i = dowpn;
19298 FFCore.reset_script_engine_data(ScriptType::Item, i);
19299 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
19300 did_scriptb=true;
19301 }
19302 }
19303
19304
6/12
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 406 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 406 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 406 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 406 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 406 times.
406 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
19305 {
19306 return false;
19307 }
19308
1/2
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
406 if(!no_jinx)
19309 did_scriptb = false;
19310 406 }
19311 else
19312 {
19313 388001 did_scriptb=false;
19314 }
19315
19316
5/6
✓ Branch 0 taken 354285 times.
✓ Branch 1 taken 34122 times.
✓ Branch 2 taken 351717 times.
✓ Branch 3 taken 2568 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 351717 times.
388407 if(attackclk || action==attacking || action==sideswimattacking)
19317 {
19318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36690 times.
36690 if(conv_forcedir > -1) dir = conv_forcedir;
19319
4/8
✓ Branch 0 taken 2568 times.
✓ Branch 1 taken 34122 times.
✓ Branch 2 taken 2568 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2568 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
36690 else if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
19320 {
19321 if((xoff==0)||diagonalMovement)
19322 {
19323 if(DrunkUp()) dir=up;
19324 if(DrunkDown()) dir=down;
19325 }
19326
19327 if((yoff==0)||diagonalMovement)
19328 {
19329 if(DrunkLeft()) dir=left;
19330 if(DrunkRight()) dir=right;
19331 }
19332 }
19333
19334 36690 bool attacked = doattack();
19335
19336 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
19337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36690 times.
36690 if(conv_forcedir > -1) dir = conv_forcedir;
19338
8/12
✓ Branch 0 taken 36690 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26520 times.
✓ Branch 3 taken 10170 times.
✓ Branch 4 taken 4890 times.
✓ Branch 5 taken 21630 times.
✓ Branch 6 taken 4890 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4890 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4890 times.
36690 else if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
19339 {
19340
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4890 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4890 if((xoff==0)||diagonalMovement)
19341 {
19342
2/2
✓ Branch 0 taken 4645 times.
✓ Branch 1 taken 245 times.
4890 if(DrunkUp()) dir=up;
19343
19344
2/2
✓ Branch 0 taken 4379 times.
✓ Branch 1 taken 511 times.
4890 if(DrunkDown()) dir=down;
19345 4890 }
19346
19347
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4890 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4890 if((yoff==0)||diagonalMovement)
19348 {
19349
2/2
✓ Branch 0 taken 4397 times.
✓ Branch 1 taken 493 times.
4890 if(DrunkLeft()) dir=left;
19350
19351
2/2
✓ Branch 0 taken 4339 times.
✓ Branch 1 taken 551 times.
4890 if(DrunkRight()) dir=right;
19352 4890 }
19353 4890 }
19354
19355
6/10
✓ Branch 0 taken 34223 times.
✓ Branch 1 taken 2467 times.
✓ Branch 2 taken 34223 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34223 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34223 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 34223 times.
36690 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
19356 {
19357 34223 return false;
19358 }
19359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2467 times.
2467 else if(!attacked)
19360 {
19361 // Spin attack - change direction
19362
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2467 if(spins>1 && attack != wHammer)
19363 {
19364 spins--;
19365
19366 if(spins%5==0)
19367 {
19368 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
19369 sfx(itemsbuf[id].usesound,pan(x.getInt()));
19370 }
19371 attackclk=1;
19372
19373 switch(dir)
19374 {
19375 case up:
19376 dir=left;
19377 break;
19378
19379 case right:
19380 dir=up;
19381 break;
19382
19383 case down:
19384 dir=right;
19385 break;
19386
19387 case left:
19388 dir=down;
19389 break;
19390 }
19391
19392 return false;
19393 }
19394 else
19395 {
19396 2467 spins=0;
19397 }
19398
19399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2467 times.
2467 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
19400 2467 else {action=none; FFCore.setHeroAction(none);}
19401 2467 attackclk=0;
19402 2467 charging=0;
19403 2467 }
19404 2467 }
19405 354184 return true;
19406 391624 }
19407 446704 void HeroClass::movehero()
19408 {
19409 446704 bool earlyret = false;
19410
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 446704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
446704 bool nohorz = (isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam);
19411
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 446704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
446704 bool novert = (isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam);
19412 446704 zfix dx, dy;
19413 446704 auto push=pushing;
19414 446704 pushing=0;
19415
19416
2/2
✓ Branch 0 taken 92520 times.
✓ Branch 1 taken 354184 times.
446704 if(!is_conveyor_stunned) //these do not apply to conveyor auto-walk
19417 {
19418
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 354121 times.
354184 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
19419 63 return;
19420
19421
2/2
✓ Branch 0 taken 113350 times.
✓ Branch 1 taken 240771 times.
354121 if(action==walking) //still walking
19422 {
19423
9/10
✓ Branch 0 taken 176973 times.
✓ Branch 1 taken 63798 times.
✓ Branch 2 taken 111511 times.
✓ Branch 3 taken 65462 times.
✓ Branch 4 taken 58564 times.
✓ Branch 5 taken 52947 times.
✓ Branch 6 taken 3076 times.
✓ Branch 7 taken 55488 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3076 times.
240771 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
19424 {
19425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3076 times.
3076 if(attackclk>0) SetAttack();
19426 3076 else {action = none; FFCore.setHeroAction(none);}
19427 3076 hero_count=-1;
19428 3076 earlyret = true;
19429 3076 goto newmove_slide;
19430 }
19431
19432 237695 autostep=false;
19433 237695 } // endif (action==walking)
19434
19435
13/24
✓ Branch 0 taken 344383 times.
✓ Branch 1 taken 6662 times.
✓ Branch 2 taken 344383 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 344383 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 344383 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 344383 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 344383 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 344383 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 344383 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 344383 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 344383 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 344383 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 344383 times.
351045 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
19436 {
19437 344383 action=none; FFCore.setHeroAction(none);
19438 344383 }
19439 351045 }
19440
19441
2/2
✓ Branch 0 taken 92520 times.
✓ Branch 1 taken 351045 times.
979650 if(is_conveyor_stunned)
19442 {
19443 92520 dx = convey_forcex;
19444 92520 dy = convey_forcey;
19445 92520 convey_forcex = 0;
19446 92520 convey_forcey = 0;
19447
1/2
✓ Branch 0 taken 92520 times.
✗ Branch 1 not taken.
92520 if(action != walking)
19448 {
19449 action = walking; FFCore.setHeroAction(walking);
19450 }
19451 92520 }
19452
1/2
✓ Branch 0 taken 351045 times.
✗ Branch 1 not taken.
351045 else if(diagonalMovement)
19453 {
19454
5/5
✓ Branch 0 taken 100590 times.
✓ Branch 1 taken 48175 times.
✓ Branch 2 taken 52157 times.
✓ Branch 3 taken 72009 times.
✓ Branch 4 taken 78114 times.
351045 switch(holddir)
19455 {
19456 case up:
19457
2/2
✓ Branch 0 taken 46260 times.
✓ Branch 1 taken 1915 times.
48175 if(!Up())
19458 {
19459 1915 holddir=-1;
19460 1915 }
19461
19462 48175 break;
19463
19464 case down:
19465
2/2
✓ Branch 0 taken 50196 times.
✓ Branch 1 taken 1961 times.
52157 if(!Down())
19466 {
19467 1961 holddir=-1;
19468 1961 }
19469
19470 52157 break;
19471
19472 case left:
19473
2/2
✓ Branch 0 taken 69690 times.
✓ Branch 1 taken 2319 times.
72009 if(!Left())
19474 {
19475 2319 holddir=-1;
19476 2319 }
19477
19478 72009 break;
19479
19480 case right:
19481
2/2
✓ Branch 0 taken 75770 times.
✓ Branch 1 taken 2344 times.
78114 if(!Right())
19482 {
19483 2344 holddir=-1;
19484 2344 }
19485
19486 78114 break;
19487
19488 default:
19489 100590 break;
19490 } //end switch
19491
19492
6/6
✓ Branch 0 taken 67280 times.
✓ Branch 1 taken 283765 times.
✓ Branch 2 taken 65360 times.
✓ Branch 3 taken 1920 times.
✓ Branch 4 taken 46260 times.
✓ Branch 5 taken 48180 times.
351045 if(DrunkUp()&&(holddir==-1||holddir==up)&&!novert)
19493 {
19494
4/10
✓ Branch 0 taken 48180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48180 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48180 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 48180 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
48180 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
19495 {
19496 48180 dir=up;
19497 48180 }
19498 48180 holddir=up;
19499
19500
5/6
✓ Branch 0 taken 7837 times.
✓ Branch 1 taken 40343 times.
✓ Branch 2 taken 7829 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7829 times.
48180 if(DrunkRight()&&shiftdir!=left&&!nohorz)
19501 {
19502 7829 shiftdir=right;
19503
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7829 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7829 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
19504
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7829 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7829 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
19505 7829 }
19506
5/6
✓ Branch 0 taken 6059 times.
✓ Branch 1 taken 34292 times.
✓ Branch 2 taken 6052 times.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6052 times.
40351 else if(DrunkLeft()&&shiftdir!=right&&!nohorz)
19507 {
19508 6052 shiftdir=left;
19509
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6052 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6052 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
19510
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6052 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6052 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
19511 6052 }
19512 else
19513 {
19514 34299 shiftdir=-1;
19515 }
19516 48180 }
19517
6/6
✓ Branch 0 taken 68782 times.
✓ Branch 1 taken 326603 times.
✓ Branch 2 taken 66817 times.
✓ Branch 3 taken 1965 times.
✓ Branch 4 taken 16621 times.
✓ Branch 5 taken 52161 times.
395385 else if(DrunkDown()&&(holddir==-1||holddir==down)&&!novert)
19518 {
19519
4/10
✓ Branch 0 taken 52161 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52161 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52161 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 52161 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
52161 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
19520 {
19521 52161 dir=down;
19522 52161 }
19523 52161 holddir=down;
19524
19525
5/6
✓ Branch 0 taken 6593 times.
✓ Branch 1 taken 45568 times.
✓ Branch 2 taken 6578 times.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6578 times.
52161 if(DrunkRight()&&shiftdir!=left&&!nohorz)
19526 {
19527 6578 shiftdir=right;
19528
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6578 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6578 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
19529
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6578 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6578 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
19530 6578 }
19531
5/6
✓ Branch 0 taken 8441 times.
✓ Branch 1 taken 37142 times.
✓ Branch 2 taken 8430 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8430 times.
45583 else if(DrunkLeft()&&shiftdir!=right&&!nohorz)
19532 {
19533 8430 shiftdir=left;
19534
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8430 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8430 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
19535
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8430 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8430 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
19536 8430 }
19537 else
19538 {
19539 37153 shiftdir=-1;
19540 }
19541 52161 }
19542
6/6
✓ Branch 0 taken 72151 times.
✓ Branch 1 taken 271073 times.
✓ Branch 2 taken 69829 times.
✓ Branch 3 taken 2322 times.
✓ Branch 4 taken 139 times.
✓ Branch 5 taken 72012 times.
343224 else if(DrunkLeft()&&(holddir==-1||holddir==left)&&!nohorz)
19543 {
19544
3/6
✓ Branch 0 taken 72012 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72012 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 72012 times.
72012 if(charging==0 && spins==0 && action != sideswimattacking)
19545 {
19546 72012 dir=left;
19547 72012 }
19548 72012 sideswimdir = left;
19549 72012 holddir=left;
19550
19551
4/6
✓ Branch 0 taken 8343 times.
✓ Branch 1 taken 63669 times.
✓ Branch 2 taken 8343 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8343 times.
72012 if(DrunkUp()&&shiftdir!=down&&!novert)
19552 {
19553 8343 shiftdir=up;
19554 8343 }
19555
5/6
✓ Branch 0 taken 7856 times.
✓ Branch 1 taken 55813 times.
✓ Branch 2 taken 7855 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7855 times.
63669 else if(DrunkDown()&&shiftdir!=up&&!novert)
19556 {
19557 7855 shiftdir=down;
19558 7855 }
19559 else
19560 {
19561 55814 shiftdir=-1;
19562 }
19563 72012 }
19564
5/6
✓ Branch 0 taken 78114 times.
✓ Branch 1 taken 193098 times.
✓ Branch 2 taken 75770 times.
✓ Branch 3 taken 2344 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 78114 times.
271212 else if(DrunkRight()&&(holddir==-1||holddir==right)&&!nohorz)
19565 {
19566
3/6
✓ Branch 0 taken 78114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 78114 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 78114 times.
78114 if(charging==0 && spins==0 && action != sideswimattacking)
19567 {
19568 78114 dir=right;
19569 78114 }
19570 78114 sideswimdir = right;
19571 78114 holddir=right;
19572
19573
4/6
✓ Branch 0 taken 10757 times.
✓ Branch 1 taken 67357 times.
✓ Branch 2 taken 10757 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10757 times.
78114 if(DrunkUp()&&shiftdir!=down&&!novert)
19574 {
19575 10757 shiftdir=up;
19576 10757 }
19577
5/6
✓ Branch 0 taken 8763 times.
✓ Branch 1 taken 58594 times.
✓ Branch 2 taken 8761 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8761 times.
67357 else if(DrunkDown()&&shiftdir!=up&&!novert)
19578 {
19579 8761 shiftdir=down;
19580 8761 }
19581 else
19582 {
19583 58596 shiftdir=-1;
19584 }
19585 78114 }
19586 else
19587 {
19588 193098 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
19589 193098 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
19590 193098 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
19591 193098 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
19592 193098 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
19593
19594
9/12
✓ Branch 0 taken 28585 times.
✓ Branch 1 taken 164513 times.
✓ Branch 2 taken 28528 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 185 times.
✓ Branch 5 taken 28343 times.
✓ Branch 6 taken 28528 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28528 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 28528 times.
✗ Branch 11 not taken.
193098 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & item_flag3))&&!(ladderx+laddery)&&z==0&&fakez==0)
19595 {
19596
8/12
✓ Branch 0 taken 579 times.
✓ Branch 1 taken 27949 times.
✓ Branch 2 taken 311 times.
✓ Branch 3 taken 268 times.
✓ Branch 4 taken 294 times.
✓ Branch 5 taken 17 times.
✓ Branch 6 taken 294 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 294 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
28528 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
19597 {
19598 //action=swimming;
19599
2/12
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 294 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
294 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
19600 {
19601 hopclk = 0xFF;
19602 }
19603 294 }
19604 28528 }
19605 193098 earlyret = true;
19606 }
19607
2/2
✓ Branch 0 taken 193098 times.
✓ Branch 1 taken 250467 times.
443565 if(earlyret)
19608 193098 dx = dy = 0;
19609 250467 else get_move(holddir,dx,dy,dir);
19610 443565 }
19611 else //4-way
19612 {
19613 shiftdir = -1;
19614 holddir = -1;
19615 if(!novert && DrunkUp())
19616 {
19617 holddir = dir = up;
19618 }
19619 else if(!novert && DrunkDown())
19620 {
19621 holddir = dir = down;
19622 }
19623 else if(!nohorz && DrunkLeft())
19624 {
19625 holddir = dir = left;
19626 }
19627 else if(!nohorz && DrunkRight())
19628 {
19629 holddir = dir = right;
19630 }
19631 get_move(holddir,dx,dy,dir);
19632 }
19633
19634 newmove_slide:
19635
1/2
✓ Branch 0 taken 354121 times.
✗ Branch 1 not taken.
354121 if(conv_forcedir > -1)
19636 dir = conv_forcedir;
19637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354121 times.
354121 if(!is_conveyor_stunned)
19638 {
19639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354121 times.
354121 bool is_inair = (z > 0 || fakez > 0);
19640 354121 auto ic = ice_combo;
19641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354121 times.
354121 if(!is_inair) //maintain momentum when jumping
19642 {
19643 354121 const int sens = 2;
19644 354121 auto ty = y+(bigHitbox?0:8);
19645 354121 int xs[] = {x+7, x+sens, x+sens, x+15-sens, x+15-sens};
19646 354121 int ys[] = {y+(bigHitbox?8:12), ty+sens, y+15-sens, ty+sens, y+15-sens};
19647 354121 bool found = false;
19648
2/2
✓ Branch 0 taken 354121 times.
✓ Branch 1 taken 1770605 times.
2124726 for(int q = 0; q < 5; ++q)
19649 {
19650 1770605 auto ice = get_icy(xs[q], ys[q], ICY_PLAYER);
19651
1/2
✓ Branch 0 taken 1770605 times.
✗ Branch 1 not taken.
1770605 if(ice)
19652 {
19653 ic = ice_combo = ice;
19654 found = true;
19655 break;
19656 }
19657 1770605 }
19658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354121 times.
354121 if(!found)
19659 354121 ic = ice_combo = 0;
19660 354121 }
19661
1/2
✓ Branch 0 taken 354121 times.
✗ Branch 1 not taken.
354121 if(script_ice_combo)
19662 {
19663 if((unsigned(script_ice_combo) < MAXCOMBOS) && check_icy(combobuf[script_ice_combo], ICY_PLAYER))
19664 ic = script_ice_combo;
19665 else ic = 0;
19666 }
19667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354121 times.
354121 if(ic)
19668 {
19669 handle_slide(combobuf[ic], dx, dy);
19670 earlyret = false;
19671 }
19672 354121 else clear_ice();
19673 354121 }
19674 else clear_ice();
19675
2/2
✓ Branch 0 taken 250467 times.
✓ Branch 1 taken 103654 times.
354121 if(earlyret)
19676 103654 return;
19677
19678
2/2
✓ Branch 0 taken 212598 times.
✓ Branch 1 taken 37869 times.
250467 if(!new_engine_move(dx,dy))
19679 37869 pushing = push+1;
19680 354184 }
19681
19682 407077 void HeroClass::get_move(int movedir, zfix& dx, zfix& dy, int32_t& facedir)
19683 {
19684 407077 dx = 0; dy = 0;
19685
6/8
✓ Branch 0 taken 250467 times.
✓ Branch 1 taken 156610 times.
✓ Branch 2 taken 250467 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 250467 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 156610 times.
✓ Branch 7 taken 407077 times.
407077 if(inlikelike || lstunclock > 0 || is_conveyor_stunned || movedir < 0)
19686 313220 return;
19687
19688 407077 zfix base_movepix(zfix(steprate) / 100);
19689 407077 zfix movepix(base_movepix);
19690 407077 zfix up_step(zfix(game->get_sideswim_up()) / 100);
19691 407077 zfix left_step(zfix(game->get_sideswim_side()) / 100);
19692 407077 zfix right_step(zfix(game->get_sideswim_side()) / 100);
19693 407077 zfix down_step(zfix(game->get_sideswim_down()) / 100);
19694 407077 std::vector<zfix*> steps;
19695
2/2
✓ Branch 0 taken 250467 times.
✓ Branch 1 taken 156610 times.
407077 steps.push_back(&movepix);
19696
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 steps.push_back(&up_step);
19697
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 steps.push_back(&left_step);
19698
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 steps.push_back(&right_step);
19699
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 steps.push_back(&down_step);
19700
19701
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 mod_steps(steps);
19702
19703
2/4
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 250467 times.
✗ Branch 3 not taken.
250467 up_step = -up_step;
19704
2/4
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 250467 times.
✗ Branch 3 not taken.
250467 left_step = -left_step;
19705
19706
19707
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 zfix step(movepix);
19708
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 zfix step_diag(movepix);
19709
19710
19711
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 if (diagonalMovement)
19712 {
19713
6/6
✓ Branch 0 taken 202287 times.
✓ Branch 1 taken 48180 times.
✓ Branch 2 taken 42009 times.
✓ Branch 3 taken 244296 times.
✓ Branch 4 taken 85859 times.
✓ Branch 5 taken 4330 times.
381493 if (((movedir == up || movedir == down) && (shiftdir == left || shiftdir == right)) ||
19714
4/4
✓ Branch 0 taken 149566 times.
✓ Branch 1 taken 94730 times.
✓ Branch 2 taken 36296 times.
✓ Branch 3 taken 185862 times.
244296 (movedir == left || movedir == right) && (shiftdir == up || shiftdir == down))
19715 {
19716
4/6
✓ Branch 0 taken 64605 times.
✓ Branch 1 taken 156610 times.
✓ Branch 2 taken 64605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64605 times.
✗ Branch 5 not taken.
221215 step = STEP_DIAGONAL(step);
19717
3/6
✓ Branch 0 taken 64605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64605 times.
✗ Branch 5 not taken.
64605 up_step = STEP_DIAGONAL(up_step);
19718
3/6
✓ Branch 0 taken 64605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64605 times.
✗ Branch 5 not taken.
64605 left_step = STEP_DIAGONAL(left_step);
19719
3/6
✓ Branch 0 taken 64605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64605 times.
✗ Branch 5 not taken.
64605 right_step = STEP_DIAGONAL(right_step);
19720
3/6
✓ Branch 0 taken 64605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64605 times.
✗ Branch 5 not taken.
64605 down_step = STEP_DIAGONAL(down_step);
19721 64605 }
19722
4/5
✓ Branch 0 taken 48180 times.
✓ Branch 1 taken 52161 times.
✓ Branch 2 taken 72012 times.
✓ Branch 3 taken 78114 times.
✗ Branch 4 not taken.
250467 switch (movedir)
19723 {
19724 case up:
19725
3/3
✓ Branch 0 taken 6052 times.
✓ Branch 1 taken 7829 times.
✓ Branch 2 taken 34299 times.
48180 switch (shiftdir)
19726 {
19727 case left:
19728
4/10
✓ Branch 0 taken 6052 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6052 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 6052 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6052 times.
✗ Branch 9 not taken.
6052 dx = IsSideSwim() ? left_step : -step;
19729 6052 break;
19730 case right:
19731
3/6
✓ Branch 0 taken 7829 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7829 times.
✓ Branch 4 taken 7829 times.
✗ Branch 5 not taken.
7829 dx = IsSideSwim() ? right_step : step;
19732 7829 break;
19733 }
19734
2/4
✓ Branch 0 taken 48180 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 48180 times.
48180 if (IsSideSwim())
19735 {
19736 dy = up_step;
19737 }
19738
2/4
✓ Branch 0 taken 48180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48180 times.
✗ Branch 3 not taken.
48180 else dy = -step;
19739 48180 break;
19740 case down:
19741
3/3
✓ Branch 0 taken 8430 times.
✓ Branch 1 taken 6578 times.
✓ Branch 2 taken 37153 times.
52161 switch (shiftdir)
19742 {
19743 case left:
19744
2/4
✓ Branch 0 taken 8430 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8430 times.
✗ Branch 3 not taken.
8430 dx = -step;
19745
2/6
✓ Branch 0 taken 8430 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8430 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8430 if (IsSideSwim()) dx = left_step;
19746 8430 break;
19747 case right:
19748
1/2
✓ Branch 0 taken 6578 times.
✗ Branch 1 not taken.
6578 dx = step;
19749
2/6
✓ Branch 0 taken 6578 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6578 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6578 if (IsSideSwim()) dx = right_step;
19750 6578 break;
19751 }
19752
3/6
✓ Branch 0 taken 52161 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 52161 times.
✓ Branch 4 taken 52161 times.
✗ Branch 5 not taken.
52161 dy = IsSideSwim() ? down_step : step;
19753 52161 break;
19754 case left:
19755
3/3
✓ Branch 0 taken 8343 times.
✓ Branch 1 taken 7855 times.
✓ Branch 2 taken 55814 times.
72012 switch (shiftdir)
19756 {
19757 case up:
19758
2/4
✓ Branch 0 taken 8343 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8343 times.
8343 if (IsSideSwim())
19759 {
19760 dy = up_step;
19761 }
19762
2/4
✓ Branch 0 taken 8343 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8343 times.
✗ Branch 3 not taken.
8343 else dy = -step;
19763 8343 break;
19764 case down:
19765
1/2
✓ Branch 0 taken 7855 times.
✗ Branch 1 not taken.
7855 dy = step;
19766
2/6
✓ Branch 0 taken 7855 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7855 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7855 if (IsSideSwim()) dy = down_step;
19767 7855 break;
19768 }
19769
4/10
✓ Branch 0 taken 72012 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72012 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 72012 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 72012 times.
✗ Branch 9 not taken.
72012 dx = IsSideSwim() ? left_step : -step;
19770 72012 break;
19771 case right:
19772
3/3
✓ Branch 0 taken 10757 times.
✓ Branch 1 taken 8761 times.
✓ Branch 2 taken 58596 times.
78114 switch (shiftdir)
19773 {
19774 case up:
19775
4/8
✓ Branch 0 taken 10757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10757 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10757 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10757 times.
✗ Branch 7 not taken.
10757 if (!IsSideSwim()) dy = -step;
19776
2/4
✓ Branch 0 taken 10757 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10757 times.
10757 if (IsSideSwim())
19777 {
19778 dy = up_step;
19779 }
19780 10757 break;
19781 case down:
19782
1/2
✓ Branch 0 taken 8761 times.
✗ Branch 1 not taken.
8761 dy = step;
19783
2/6
✓ Branch 0 taken 8761 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8761 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8761 if (IsSideSwim()) dy = down_step;
19784 8761 break;
19785 }
19786
3/6
✓ Branch 0 taken 78114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78114 times.
✓ Branch 4 taken 78114 times.
✗ Branch 5 not taken.
78114 dx = IsSideSwim() ? right_step : step;
19787 78114 break;
19788 };
19789 250467 }
19790 else
19791 {
19792 switch (movedir)
19793 {
19794 case up:
19795 dy = IsSideSwim() ? up_step : -step;
19796 break;
19797 case down:
19798 dy = IsSideSwim() ? down_step : step;
19799 break;
19800 case left:
19801 dx = IsSideSwim() ? left_step : -step;
19802 break;
19803 case right:
19804 dx = IsSideSwim() ? right_step : step;
19805 break;
19806 };
19807 }
19808
19809
2/8
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 250467 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
250467 if (isSideViewHero() && slopeid)
19810 {
19811 dy += (dx*slopeid);
19812 }
19813
19814
6/18
✗ Branch 0 not taken.
✓ Branch 1 taken 250467 times.
✓ Branch 2 taken 250467 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 250467 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 250467 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 250467 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 250467 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
250467 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (movedir == up || movedir == down))) //!DIRECTION SET
19815 {
19816 250467 facedir = movedir;
19817 250467 }
19818 else if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (movedir == up || movedir == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
19819 {
19820 facedir = shiftdir;
19821 }
19822 563687 }
19823
19824 250467 bool HeroClass::new_engine_move(zfix dx, zfix dy) //no collision check
19825 {
19826
3/4
✓ Branch 0 taken 71452 times.
✓ Branch 1 taken 179015 times.
✓ Branch 2 taken 71452 times.
✗ Branch 3 not taken.
250467 if(!dx && !dy) return true;
19827
5/8
✓ Branch 0 taken 244177 times.
✓ Branch 1 taken 6290 times.
✓ Branch 2 taken 244177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 244177 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 244177 times.
250467 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
19828 {
19829 244177 herostep();
19830
19831 //ack... don't walk if in midair! -DD
19832
5/14
✓ Branch 0 taken 244177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 244177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 244177 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 244177 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 244177 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
244177 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(this) && !getOnSideviewLadder()))
19833 {
19834 244177 action=walking; FFCore.setHeroAction(walking);
19835 244177 }
19836
19837
2/2
✓ Branch 0 taken 231372 times.
✓ Branch 1 taken 12805 times.
244177 if(++hero_count > (16*hero_animation_speed))
19838 12805 hero_count=0;
19839 244177 }
19840
2/2
✓ Branch 0 taken 3148 times.
✓ Branch 1 taken 3142 times.
6290 else if(!(frame & 1))
19841 {
19842 3142 herostep();
19843 3142 }
19844
19845 250467 bool ret = true;
19846
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 250467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
250467 if(charging==0 || attack!=wHammer)
19847 {
19848 250467 ret = movexy(dx,dy,false,false,true);
19849 250467 }
19850 250467 return ret;
19851 250467 }
19852
19853 7410762 void HeroClass::moveOld(int32_t d2)
19854 {
19855 static bool totalskip = false;
19856
19857
3/6
✓ Branch 0 taken 7410762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7410762 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7410762 times.
7410762 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
19858 return;
19859
19860 7410762 int32_t dx=0,dy=0;
19861 7410762 int32_t xstep=lsteps[x.getInt()&7];
19862 7410762 int32_t ystep=lsteps[y.getInt()&7];
19863 7410762 int32_t z3skip=0;
19864 7410762 int32_t z3diagskip=0;
19865
5/6
✓ Branch 0 taken 200742 times.
✓ Branch 1 taken 7210020 times.
✓ Branch 2 taken 200680 times.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
14620844 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && ((z==0 && fakez == 0) || tmpscr->flags2&fAIRCOMBOS)) ||
19866
5/6
✓ Branch 0 taken 149353 times.
✓ Branch 1 taken 7060729 times.
✓ Branch 2 taken 81755 times.
✓ Branch 3 taken 67598 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 81755 times.
7210082 (isSideViewHero() && (on_sideview_solid_oldpos(this)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement);
19867
2/2
✓ Branch 0 taken 7384947 times.
✓ Branch 1 taken 25815 times.
7410762 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & item_flag10);
19868 7410762 bool is_swimming = (action == swimming);
19869
19870 //slow walk combo, or charging, moves at 2/3 speed
19871 if(
19872
4/4
✓ Branch 0 taken 7309928 times.
✓ Branch 1 taken 100834 times.
✓ Branch 2 taken 201043 times.
✓ Branch 3 taken 7108885 times.
7511596 (!is_swimming && (slowcharging ^ slowcombo))||
19873
2/2
✓ Branch 0 taken 100834 times.
✓ Branch 1 taken 7108885 times.
7209719 (is_swimming && (zinit.hero_swim_speed>60))
19874 )
19875 {
19876 301877 totalskip = false;
19877
19878
2/2
✓ Branch 0 taken 49244 times.
✓ Branch 1 taken 252633 times.
301877 if(diagonalMovement)
19879 {
19880 49244 skipstep=(skipstep+1)%6;
19881
19882
2/2
✓ Branch 0 taken 25024 times.
✓ Branch 1 taken 24220 times.
49244 if(skipstep%2==0) z3skip=1;
19883 25024 else z3skip=0;
19884
19885
2/2
✓ Branch 0 taken 33205 times.
✓ Branch 1 taken 16039 times.
49244 if(skipstep%3==0) z3diagskip=1;
19886 33205 else z3diagskip=0;
19887 49244 }
19888 else
19889 {
19890
2/2
✓ Branch 0 taken 165339 times.
✓ Branch 1 taken 87294 times.
252633 if(d2<left)
19891 {
19892
2/2
✓ Branch 0 taken 99954 times.
✓ Branch 1 taken 65385 times.
165339 if(ystep>1)
19893 {
19894 65385 skipstep^=1;
19895 65385 ystep=skipstep;
19896 65385 }
19897 165339 }
19898 else
19899 {
19900
2/2
✓ Branch 0 taken 53050 times.
✓ Branch 1 taken 34244 times.
87294 if(xstep>1)
19901 {
19902 34244 skipstep^=1;
19903 34244 xstep=skipstep;
19904 34244 }
19905 }
19906 }
19907 301877 }
19908 // else if(is_swimming || (slowcharging && slowcombo))
19909 else if(
19910
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7108885 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7108996 (is_swimming && (zinit.hero_swim_speed<60))||
19911
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 7108774 times.
7108885 (slowcharging && slowcombo)
19912 )
19913 {
19914 //swimming, or charging on a slow combo, moves at 1/2 speed
19915 111 totalskip = !totalskip;
19916
19917
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(diagonalMovement)
19918 {
19919 skipstep=0;
19920 }
19921 111 }
19922 else
19923 {
19924 7108774 totalskip = false;
19925
19926
2/2
✓ Branch 0 taken 5123814 times.
✓ Branch 1 taken 1984960 times.
7108774 if(diagonalMovement)
19927 {
19928 1984960 skipstep=0;
19929 1984960 }
19930 }
19931
19932
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 7410706 times.
7410762 if(!totalskip)
19933 {
19934
2/2
✓ Branch 0 taken 2034204 times.
✓ Branch 1 taken 5376502 times.
7410706 if(diagonalMovement)
19935 {
19936
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 439712 times.
✓ Branch 2 taken 372274 times.
✓ Branch 3 taken 640047 times.
✓ Branch 4 taken 582171 times.
2034204 switch(d2)
19937 {
19938 case up:
19939
2/2
✓ Branch 0 taken 45201 times.
✓ Branch 1 taken 394511 times.
439712 if(shiftdir==left)
19940 {
19941
2/2
✓ Branch 0 taken 35875 times.
✓ Branch 1 taken 9326 times.
45201 if(walkable)
19942 {
19943 35875 dy-=1-z3diagskip;
19944 35875 dx-=1-z3diagskip;
19945 35875 z3step=2;
19946 35875 }
19947 else
19948 {
19949 9326 dx-=1-z3diagskip;
19950 9326 z3step=2;
19951 }
19952 45201 }
19953
2/2
✓ Branch 0 taken 54111 times.
✓ Branch 1 taken 340400 times.
394511 else if(shiftdir==right)
19954 {
19955
2/2
✓ Branch 0 taken 43412 times.
✓ Branch 1 taken 10699 times.
54111 if(walkable)
19956 {
19957 43412 dy-=1-z3diagskip;
19958 43412 dx+=1-z3diagskip;
19959 43412 z3step=2;
19960 43412 }
19961 else
19962 {
19963 10699 dx+=1-z3diagskip;
19964 10699 z3step=2;
19965 }
19966 54111 }
19967 else
19968 {
19969
2/2
✓ Branch 0 taken 57988 times.
✓ Branch 1 taken 282412 times.
340400 if(walkable)
19970 {
19971 282412 dy-=z3step-z3skip;
19972 282412 z3step=(z3step%2)+1;
19973 282412 }
19974 }
19975
19976 439712 break;
19977
19978 case down:
19979
2/2
✓ Branch 0 taken 50651 times.
✓ Branch 1 taken 321623 times.
372274 if(shiftdir==left)
19980 {
19981
2/2
✓ Branch 0 taken 38388 times.
✓ Branch 1 taken 12263 times.
50651 if(walkable)
19982 {
19983 38388 dy+=1-z3diagskip;
19984 38388 dx-=1-z3diagskip;
19985 38388 z3step=2;
19986 38388 }
19987 else
19988 {
19989 12263 dx-=1-z3diagskip;
19990 12263 z3step=2;
19991 }
19992 50651 }
19993
2/2
✓ Branch 0 taken 51930 times.
✓ Branch 1 taken 269693 times.
321623 else if(shiftdir==right)
19994 {
19995
2/2
✓ Branch 0 taken 39650 times.
✓ Branch 1 taken 12280 times.
51930 if(walkable)
19996 {
19997 39650 dy+=1-z3diagskip;
19998 39650 dx+=1-z3diagskip;
19999 39650 z3step=2;
20000 39650 }
20001 else
20002 {
20003 12280 dx+=1-z3diagskip;
20004 12280 z3step=2;
20005 }
20006 51930 }
20007 else
20008 {
20009
2/2
✓ Branch 0 taken 44791 times.
✓ Branch 1 taken 224902 times.
269693 if(walkable)
20010 {
20011 224902 dy+=z3step-z3skip;
20012 224902 z3step=(z3step%2)+1;
20013 224902 }
20014 }
20015
20016 372274 break;
20017
20018 case right:
20019
2/2
✓ Branch 0 taken 570449 times.
✓ Branch 1 taken 69598 times.
640047 if(shiftdir==up)
20020 {
20021
2/2
✓ Branch 0 taken 57862 times.
✓ Branch 1 taken 11736 times.
69598 if(walkable)
20022 {
20023 57862 dy-=1-z3diagskip;
20024 57862 dx+=1-z3diagskip;
20025 57862 z3step=2;
20026 57862 }
20027 else
20028 {
20029 11736 dy-=1-z3diagskip;
20030 11736 z3step=2;
20031 }
20032 69598 }
20033
2/2
✓ Branch 0 taken 54246 times.
✓ Branch 1 taken 516203 times.
570449 else if(shiftdir==down)
20034 {
20035
2/2
✓ Branch 0 taken 44949 times.
✓ Branch 1 taken 9297 times.
54246 if(walkable)
20036 {
20037 44949 dy+=1-z3diagskip;
20038 44949 dx+=1-z3diagskip;
20039 44949 z3step=2;
20040 44949 }
20041 else
20042 {
20043 9297 dy+=1-z3diagskip;
20044 9297 z3step=2;
20045 }
20046 54246 }
20047 else
20048 {
20049
2/2
✓ Branch 0 taken 59862 times.
✓ Branch 1 taken 456341 times.
516203 if(walkable)
20050 {
20051 456341 dx+=z3step-z3skip;
20052 456341 z3step=(z3step%2)+1;
20053 456341 }
20054 }
20055
20056 640047 break;
20057
20058 case left:
20059
2/2
✓ Branch 0 taken 516604 times.
✓ Branch 1 taken 65567 times.
582171 if(shiftdir==up)
20060 {
20061
2/2
✓ Branch 0 taken 55591 times.
✓ Branch 1 taken 9976 times.
65567 if(walkable)
20062 {
20063 55591 dy-=1-z3diagskip;
20064 55591 dx-=1-z3diagskip;
20065 55591 z3step=2;
20066 55591 }
20067 else
20068 {
20069 9976 dy-=1-z3diagskip;
20070 9976 z3step=2;
20071 }
20072 65567 }
20073
2/2
✓ Branch 0 taken 50527 times.
✓ Branch 1 taken 466077 times.
516604 else if(shiftdir==down)
20074 {
20075
2/2
✓ Branch 0 taken 42583 times.
✓ Branch 1 taken 7944 times.
50527 if(walkable)
20076 {
20077 42583 dy+=1-z3diagskip;
20078 42583 dx-=1-z3diagskip;
20079 42583 z3step=2;
20080 42583 }
20081 else
20082 {
20083 7944 dy+=1-z3diagskip;
20084 7944 z3step=2;
20085 }
20086 50527 }
20087 else
20088 {
20089
2/2
✓ Branch 0 taken 49315 times.
✓ Branch 1 taken 416762 times.
466077 if(walkable)
20090 {
20091 416762 dx-=z3step-z3skip;
20092 416762 z3step=(z3step%2)+1;
20093 416762 }
20094 }
20095
20096 582171 break;
20097 }
20098 2034204 }
20099 else
20100 {
20101
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1267887 times.
✓ Branch 2 taken 1035600 times.
✓ Branch 3 taken 1490381 times.
✓ Branch 4 taken 1582634 times.
5376502 switch(d2)
20102 {
20103 case up:
20104
7/14
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 1267579 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 308 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 308 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 308 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 308 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
1267887 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy-=ystep;
20105
20106 1267887 break;
20107
20108 case down:
20109
7/14
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1035546 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 54 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 54 times.
1035600 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy+=ystep;
20110
20111 1035600 break;
20112
20113 case left:
20114 1490381 dx-=xstep;
20115 1490381 break;
20116
20117 case right:
20118 1582634 dx+=xstep;
20119 1582634 break;
20120 }
20121 }
20122 7410706 }
20123
20124
8/16
✓ Branch 0 taken 25815 times.
✓ Branch 1 taken 7384947 times.
✓ Branch 2 taken 7384668 times.
✓ Branch 3 taken 26094 times.
✓ Branch 4 taken 7384467 times.
✓ Branch 5 taken 201 times.
✓ Branch 6 taken 7384467 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 7384467 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
7410762 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
20125 {
20126 7384467 dir=d2;
20127 7384467 }
20128
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 26295 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
26295 else if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
20129 {
20130 dir = shiftdir;
20131 }
20132
20133
3/4
✓ Branch 0 taken 7309928 times.
✓ Branch 1 taken 100834 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7309928 times.
7410762 if(action != swimming && !IsSideSwim())
20134 {
20135 7309928 herostep();
20136
20137 //ack... don't walk if in midair! -DD
20138
12/14
✓ Branch 0 taken 7284113 times.
✓ Branch 1 taken 25815 times.
✓ Branch 2 taken 7283834 times.
✓ Branch 3 taken 279 times.
✓ Branch 4 taken 7273969 times.
✓ Branch 5 taken 9865 times.
✓ Branch 6 taken 7273969 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 149353 times.
✓ Branch 9 taken 7124616 times.
✓ Branch 10 taken 81755 times.
✓ Branch 11 taken 67598 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 81755 times.
7309928 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(this) && !getOnSideviewLadder()))
20139 {
20140 7192214 action=walking; FFCore.setHeroAction(walking);
20141 7192214 }
20142
20143
2/2
✓ Branch 0 taken 6918933 times.
✓ Branch 1 taken 390995 times.
7309928 if(++hero_count > (16*hero_animation_speed))
20144 390995 hero_count=0;
20145 7309928 }
20146
2/2
✓ Branch 0 taken 50397 times.
✓ Branch 1 taken 50437 times.
100834 else if(!(frame & 1))
20147 {
20148 50437 herostep();
20149 50437 }
20150
20151
3/4
✓ Branch 0 taken 25815 times.
✓ Branch 1 taken 7384947 times.
✓ Branch 2 taken 25815 times.
✗ Branch 3 not taken.
7410762 if(charging==0 || attack!=wHammer)
20152 {
20153 7410762 sprite::move((zfix)dx,(zfix)dy);
20154 7410762 }
20155 7410762 }
20156 7751224 void HeroClass::moveOld2(int32_t d2, int32_t forceRate)
20157 {
20158
4/6
✓ Branch 0 taken 7748625 times.
✓ Branch 1 taken 2599 times.
✓ Branch 2 taken 7748625 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7748625 times.
7751224 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
20159 2599 return;
20160
20161
3/4
✓ Branch 0 taken 7410762 times.
✓ Branch 1 taken 337863 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7410762 times.
7748625 if(!get_qr(qr_NEW_HERO_MOVEMENT) && !IsSideSwim())
20162 {
20163 7410762 moveOld(d2);
20164 7410762 return;
20165 }
20166
20167
4/8
✓ Branch 0 taken 8657 times.
✓ Branch 1 taken 329206 times.
✓ Branch 2 taken 8657 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8657 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
667069 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1) && ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS)) ||
20168
5/6
✓ Branch 0 taken 3681 times.
✓ Branch 1 taken 325525 times.
✓ Branch 2 taken 1575 times.
✓ Branch 3 taken 2106 times.
✓ Branch 4 taken 3681 times.
✗ Branch 5 not taken.
329206 (isSideViewHero() && (on_sideview_solid_oldpos(this)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1));
20169 //!DIMITODO: add QR for slow combos under hero
20170
4/4
✓ Branch 0 taken 329206 times.
✓ Branch 1 taken 8657 times.
✓ Branch 2 taken 8657 times.
✓ Branch 3 taken 17314 times.
355177 if(slowcombo) for (int32_t i = 0; i <= 1; ++i)
20171 {
20172
2/2
✓ Branch 0 taken 584 times.
✓ Branch 1 taken 16730 times.
17314 if(tmpscr2[i].valid!=0)
20173 {
20174
2/2
✓ Branch 0 taken 11904 times.
✓ Branch 1 taken 4826 times.
16730 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20175 {
20176
2/4
✓ Branch 0 taken 11904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11904 times.
✗ Branch 3 not taken.
11904 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i])))
20177 {
20178 slowcombo = false;
20179 break;
20180 }
20181 11904 }
20182 else
20183 {
20184
2/4
✓ Branch 0 taken 4826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4826 times.
✗ Branch 3 not taken.
4826 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i])))
20185 {
20186 slowcombo = false;
20187 break;
20188 }
20189 }
20190 16730 }
20191 25971 }
20192
2/2
✓ Branch 0 taken 335594 times.
✓ Branch 1 taken 2269 times.
337863 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & item_flag10);
20193 337863 bool is_swimming = (action == swimming);
20194 337863 bool fastSwim = (zinit.hero_swim_speed>60);
20195 337863 zfix rate(steprate);
20196 337863 int32_t shieldid = getCurrentActiveShield();
20197
1/2
✓ Branch 0 taken 337863 times.
✗ Branch 1 not taken.
337863 if(shieldid > -1)
20198 {
20199 itemdata const& shield = itemsbuf[shieldid];
20200 if(shield.flags & item_flag10) //Change Speed flag
20201 {
20202 zfix perc = shield.misc7;
20203 perc /= 100;
20204 if(perc < 0)
20205 perc = (perc*-1)+1;
20206 rate = (rate * perc) + shield.misc8;
20207 }
20208 }
20209
20210 337863 zfix dx, dy;
20211 337863 zfix movepix(rate / 100);
20212 337863 zfix step(movepix);
20213 337863 zfix step_diag(movepix);
20214 337863 zfix up_step(game->get_sideswim_up() / -100.0);
20215 337863 zfix left_step(game->get_sideswim_side() / -100.0);
20216 337863 zfix right_step(game->get_sideswim_side() / 100.0);
20217 337863 zfix down_step(game->get_sideswim_down() / 100.0);
20218 337863 bool checkladder = false;
20219
20220
2/2
✓ Branch 0 taken 337661 times.
✓ Branch 1 taken 202 times.
337863 if(hero_newstep > movepix) hero_newstep = movepix;
20221
2/2
✓ Branch 0 taken 337661 times.
✓ Branch 1 taken 202 times.
337863 if(hero_newstep_diag > movepix) hero_newstep_diag = movepix;
20222 //2/3 speed
20223
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 337863 times.
✓ Branch 2 taken 327019 times.
✓ Branch 3 taken 327019 times.
✓ Branch 4 taken 337863 times.
✓ Branch 5 taken 327019 times.
337863 if((is_swimming && fastSwim) || (!is_swimming && (slowcharging ^ slowcombo)))
20224 {
20225 664882 step = ((step / 3.0) * 2);
20226 664882 step_diag = ((step_diag / 3.0) * 2);
20227 664882 up_step = ((up_step / 3.0) * 2);
20228 664882 left_step = ((left_step / 3.0) * 2);
20229 664882 right_step = ((right_step / 3.0) * 2);
20230 664882 down_step = ((down_step / 3.0) * 2);
20231 664882 }
20232 //1/2 speed
20233
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 327019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
✓ Branch 5 taken 326988 times.
327019 else if((is_swimming && !fastSwim) || (slowcharging && slowcombo))
20234 {
20235 31 step /= 2;
20236 31 step_diag /= 2;
20237 31 up_step /= 2;
20238 31 left_step /= 2;
20239 31 right_step /= 2;
20240 31 down_step /= 2;
20241 31 }
20242 //normal speed
20243 else
20244 {
20245 //no modification
20246 }
20247
20248
1/2
✓ Branch 0 taken 337863 times.
✗ Branch 1 not taken.
337863 if(diagonalMovement)
20249 {
20250
6/6
✓ Branch 0 taken 265547 times.
✓ Branch 1 taken 72316 times.
✓ Branch 2 taken 281406 times.
✓ Branch 3 taken 15859 times.
✓ Branch 4 taken 124917 times.
✓ Branch 5 taken 228805 times.
513199 if(((d2 == up || d2 == down) && (shiftdir == left || shiftdir == right)) ||
20251
4/4
✓ Branch 0 taken 207719 times.
✓ Branch 1 taken 191860 times.
✓ Branch 2 taken 17914 times.
✓ Branch 3 taken 189805 times.
15859 (d2 == left || d2 == right) && (shiftdir == up || shiftdir == down))
20252 {
20253
3/4
✓ Branch 0 taken 71344 times.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 71344 times.
529058 if(hero_newstep > 0 && hero_newstep_diag > 0)
20254 {
20255 71344 step = STEP_DIAGONAL(step);
20256 71344 step_diag = STEP_DIAGONAL(step_diag);
20257 71344 up_step = STEP_DIAGONAL(up_step);
20258 71344 left_step = STEP_DIAGONAL(left_step);
20259 71344 right_step = STEP_DIAGONAL(right_step);
20260 71344 down_step = STEP_DIAGONAL(down_step);
20261 71344 }
20262 71448 }
20263
2/2
✓ Branch 0 taken 228774 times.
✓ Branch 1 taken 32479 times.
261253 if(hero_newstep < step) step = hero_newstep; //handle collision
20264
2/2
✓ Branch 0 taken 250207 times.
✓ Branch 1 taken 11046 times.
261253 if(hero_newstep_diag < step_diag) step_diag = hero_newstep_diag; //handle collision
20265
5/5
✓ Branch 0 taken 76610 times.
✓ Branch 1 taken 72316 times.
✓ Branch 2 taken 69565 times.
✓ Branch 3 taken 96588 times.
✓ Branch 4 taken 99394 times.
261253 switch(d2)
20266 {
20267 case up:
20268
3/3
✓ Branch 0 taken 57008 times.
✓ Branch 1 taken 7436 times.
✓ Branch 2 taken 7872 times.
72316 switch(shiftdir)
20269 {
20270 case left:
20271 7436 dx = -step_diag;
20272
1/2
✓ Branch 0 taken 7436 times.
✗ Branch 1 not taken.
7436 if (IsSideSwim()) dx = left_step;
20273 7436 break;
20274 case right:
20275 7872 dx = step_diag;
20276
1/2
✓ Branch 0 taken 7872 times.
✗ Branch 1 not taken.
7872 if (IsSideSwim()) dx = right_step;
20277 7872 break;
20278 }
20279
2/2
✓ Branch 0 taken 10651 times.
✓ Branch 1 taken 61665 times.
72316 if(walkable)
20280 {
20281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61665 times.
61665 if (!IsSideSwim()) dy = -step;
20282
1/2
✓ Branch 0 taken 61665 times.
✗ Branch 1 not taken.
61665 if (IsSideSwim())
20283 {
20284 dy = up_step;
20285 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
20286 }
20287 61665 }
20288 72316 break;
20289 case down:
20290
3/3
✓ Branch 0 taken 51317 times.
✓ Branch 1 taken 9528 times.
✓ Branch 2 taken 8720 times.
69565 switch(shiftdir)
20291 {
20292 case left:
20293 9528 dx = -step_diag;
20294
1/2
✓ Branch 0 taken 9528 times.
✗ Branch 1 not taken.
9528 if (IsSideSwim()) dx = left_step;
20295 9528 break;
20296 case right:
20297 8720 dx = step_diag;
20298
1/2
✓ Branch 0 taken 8720 times.
✗ Branch 1 not taken.
8720 if (IsSideSwim()) dx = right_step;
20299 8720 break;
20300 }
20301
2/2
✓ Branch 0 taken 8345 times.
✓ Branch 1 taken 61220 times.
69565 if(walkable)
20302 {
20303 61220 dy = step;
20304
1/2
✓ Branch 0 taken 61220 times.
✗ Branch 1 not taken.
61220 if (IsSideSwim()) dy = down_step;
20305 61220 }
20306 69565 break;
20307 case left:
20308
3/3
✓ Branch 0 taken 77532 times.
✓ Branch 1 taken 10242 times.
✓ Branch 2 taken 8814 times.
96588 switch(shiftdir)
20309 {
20310 case up:
20311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10242 times.
10242 if (!IsSideSwim()) dy = -step_diag;
20312
1/2
✓ Branch 0 taken 10242 times.
✗ Branch 1 not taken.
10242 if (IsSideSwim())
20313 {
20314 dy = up_step;
20315 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
20316 }
20317 10242 break;
20318 case down:
20319 8814 dy = step_diag;
20320
1/2
✓ Branch 0 taken 8814 times.
✗ Branch 1 not taken.
8814 if (IsSideSwim()) dy = down_step;
20321 8814 break;
20322 }
20323
2/2
✓ Branch 0 taken 9075 times.
✓ Branch 1 taken 87513 times.
96588 if(walkable)
20324 {
20325 87513 dx = -step;
20326
1/2
✓ Branch 0 taken 87513 times.
✗ Branch 1 not taken.
87513 if (IsSideSwim()) dx = left_step;
20327 87513 }
20328 96588 break;
20329 case right:
20330
3/3
✓ Branch 0 taken 80558 times.
✓ Branch 1 taken 10404 times.
✓ Branch 2 taken 8432 times.
99394 switch(shiftdir)
20331 {
20332 case up:
20333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10404 times.
10404 if (!IsSideSwim()) dy = -step_diag;
20334
1/2
✓ Branch 0 taken 10404 times.
✗ Branch 1 not taken.
10404 if (IsSideSwim())
20335 {
20336 dy = up_step;
20337 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
20338 }
20339 10404 break;
20340 case down:
20341 8432 dy = step_diag;
20342
1/2
✓ Branch 0 taken 8432 times.
✗ Branch 1 not taken.
8432 if (IsSideSwim()) dy = down_step;
20343 8432 break;
20344 }
20345
2/2
✓ Branch 0 taken 9683 times.
✓ Branch 1 taken 89711 times.
99394 if(walkable)
20346 {
20347 89711 dx = step;
20348
1/2
✓ Branch 0 taken 89711 times.
✗ Branch 1 not taken.
89711 if (IsSideSwim()) dx = right_step;
20349 89711 }
20350 99394 break;
20351 };
20352 414473 }
20353 else
20354 {
20355 if(hero_newstep < step) step = hero_newstep; //handle collision
20356 switch(d2)
20357 {
20358 case up:
20359 dy -= step;
20360 if (IsSideSwim()) dy = up_step;
20361 break;
20362 case down:
20363 dy += step;
20364 if (IsSideSwim()) dy = down_step;
20365 break;
20366 case left:
20367 dx -= step;
20368 if (IsSideSwim()) dx = left_step;
20369 break;
20370 case right:
20371 dx += step;
20372 if (IsSideSwim()) dx = right_step;
20373 break;
20374 };
20375 }
20376 414473 hero_newstep = movepix;
20377 414473 hero_newstep_diag = movepix;
20378
20379
7/16
✓ Branch 0 taken 2269 times.
✓ Branch 1 taken 412204 times.
✓ Branch 2 taken 335594 times.
✓ Branch 3 taken 78879 times.
✓ Branch 4 taken 335594 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 335594 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 335594 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
414473 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
20380 {
20381 335594 dir=d2;
20382 335594 }
20383
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 78879 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
78879 else if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
20384 {
20385 dir = shiftdir;
20386 }
20387
2/2
✓ Branch 0 taken 414216 times.
✓ Branch 1 taken 257 times.
414473 if(forceRate > -1)
20388 {
20389 257 checkladder = false;
20390
2/3
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 245 times.
257 switch(dir)
20391 {
20392 case right:
20393 case r_up:
20394 case r_down:
20395 12 dx = zfix(forceRate) / 100;
20396 12 break;
20397 case left:
20398 case l_up:
20399 case l_down:
20400 dx = zfix(-forceRate) / 100;
20401 break;
20402 default:
20403 245 dx = 0;
20404 245 }
20405
3/3
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 12 times.
257 switch(dir)
20406 {
20407 case down:
20408 case r_down:
20409 case l_down:
20410 17 dy = zfix(forceRate) / 100;
20411 17 break;
20412 case up:
20413 case r_up:
20414 case l_up:
20415 228 dy = zfix(-forceRate) / 100;
20416 228 break;
20417 default:
20418 12 dy = 0;
20419 12 }
20420 257 }
20421
4/4
✓ Branch 0 taken 3681 times.
✓ Branch 1 taken 410792 times.
✓ Branch 2 taken 2574 times.
✓ Branch 3 taken 1107 times.
414473 if (isSideViewHero() && slopeid)
20422 {
20423 1107 dy += (dx * slopeid);
20424 1107 }
20425
4/4
✓ Branch 0 taken 127341 times.
✓ Branch 1 taken 287132 times.
✓ Branch 2 taken 100899 times.
✓ Branch 3 taken 26442 times.
414473 if(dx == 0 && dy == 0) return;
20426
5/8
✓ Branch 0 taken 311421 times.
✓ Branch 1 taken 76610 times.
✓ Branch 2 taken 311421 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 311421 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 311421 times.
388031 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
20427 {
20428 311421 herostep();
20429
20430 //ack... don't walk if in midair! -DD
20431
11/14
✓ Branch 0 taken 309418 times.
✓ Branch 1 taken 2003 times.
✓ Branch 2 taken 309418 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 306273 times.
✓ Branch 5 taken 3145 times.
✓ Branch 6 taken 306273 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3585 times.
✓ Branch 9 taken 302688 times.
✓ Branch 10 taken 1524 times.
✓ Branch 11 taken 2061 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1524 times.
311421 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(this) && !getOnSideviewLadder()))
20432 {
20433 304749 action=walking; FFCore.setHeroAction(walking);
20434 304749 }
20435
20436
2/2
✓ Branch 0 taken 295088 times.
✓ Branch 1 taken 16333 times.
311421 if(++hero_count > (16*hero_animation_speed))
20437 16333 hero_count=0;
20438 311421 }
20439
1/2
✓ Branch 0 taken 76610 times.
✗ Branch 1 not taken.
76610 else if(!(frame & 1))
20440 {
20441 herostep();
20442 }
20443
20444
4/4
✓ Branch 0 taken 2003 times.
✓ Branch 1 taken 386028 times.
✓ Branch 2 taken 74607 times.
✓ Branch 3 taken 72604 times.
388031 if(charging==0 || attack!=wHammer)
20445 {
20446 460635 sprite::move(dx, dy);
20447 460635 WalkflagInfo info;
20448 460635 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
20449 460635 execute(info);
20450
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 311421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 311421 times.
✗ Branch 7 not taken.
460635 if (checkladder && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y + 8 - (bigHitbox * 8) - 4) > 0)
20451 {
20452 if (game->get_sideswim_jump() != 0)
20453 {
20454 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
20455 sfx(WAV_ZN1SPLASH,(int32_t)x);
20456 hopclk = 0;
20457 if (charging || spins) action = attacking;
20458 else action = none;
20459 }
20460 else
20461 {
20462 sprite::move(0_zf, zfix(-1*dy));
20463 }
20464 }
20465 311421 }
20466 7823828 }
20467
20468 32262836 HeroClass::WalkflagInfo HeroClass::walkflag(zfix fx,zfix fy,int32_t cnt,byte d2)
20469 {
20470 32262836 return walkflag(fx.getInt(), fy.getInt(), cnt, d2);
20471 }
20472 32262836 HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,byte d2)
20473 {
20474 32262836 WalkflagInfo ret;
20475
20476 32262836 wx = vbound(wx, -1, 256);
20477 32262836 wy = vbound(wy, -1, 176);
20478
20479
8/8
✓ Branch 0 taken 32171878 times.
✓ Branch 1 taken 90958 times.
✓ Branch 2 taken 32083296 times.
✓ Branch 3 taken 88582 times.
✓ Branch 4 taken 32083003 times.
✓ Branch 5 taken 293 times.
✓ Branch 6 taken 7816 times.
✓ Branch 7 taken 32075187 times.
32262836 if (wx < 0 || wx > 255 || wy < 0 || wy > 175)
20480 {
20481 187649 ret.setUnwalkable(false);
20482 187649 return ret;
20483 }
20484
20485
2/2
✓ Branch 0 taken 44786 times.
✓ Branch 1 taken 32030401 times.
32075187 if(toogam)
20486 {
20487 44786 ret.setUnwalkable(false);
20488 44786 return ret;
20489 }
20490
20491
4/4
✓ Branch 0 taken 547172 times.
✓ Branch 1 taken 31483229 times.
✓ Branch 2 taken 522138 times.
✓ Branch 3 taken 25034 times.
32030401 if(blockpath && wy<(bigHitbox?80:88))
20492 {
20493 25034 ret.setUnwalkable(true);
20494 25034 return ret;
20495 }
20496
20497
4/4
✓ Branch 0 taken 495981 times.
✓ Branch 1 taken 31509386 times.
✓ Branch 2 taken 311830 times.
✓ Branch 3 taken 184151 times.
32005367 if(mblock2.active() && mblock2.hit(wx,wy,0,1,1,1))
20498 {
20499 184151 ret.setUnwalkable(true);
20500 184151 return ret;
20501 }
20502
20503
2/2
✓ Branch 0 taken 1100 times.
✓ Branch 1 taken 31820116 times.
31821216 if (collide_object(wx, wy,1, 1))
20504 {
20505 1100 ret.setUnwalkable(true);
20506 1100 return ret;
20507 }
20508
20509
18/22
✓ Branch 0 taken 15315079 times.
✓ Branch 1 taken 16505037 times.
✓ Branch 2 taken 14863586 times.
✓ Branch 3 taken 451493 times.
✓ Branch 4 taken 14342564 times.
✓ Branch 5 taken 521022 times.
✓ Branch 6 taken 517624 times.
✓ Branch 7 taken 3398 times.
✓ Branch 8 taken 517624 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 517624 times.
✓ Branch 12 taken 2095 times.
✓ Branch 13 taken 1303 times.
✓ Branch 14 taken 281863 times.
✓ Branch 15 taken 239159 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 239159 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 239159 times.
✓ Branch 20 taken 31083 times.
✓ Branch 21 taken 31789033 times.
32132421 if(isdungeon() && currscr<128 && wy<(bigHitbox?32:40) && (((diagonalMovement||NO_GRIDLOCK)?(x<=112||x>=128):x!=120) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
20510
2/2
✓ Branch 0 taken 30442 times.
✓ Branch 1 taken 208717 times.
521022 && !get_qr(qr_FREEFORM))
20511 {
20512 31083 ret.setUnwalkable(true);
20513 31083 return ret;
20514 }
20515
20516
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31789033 times.
✓ Branch 2 taken 31789033 times.
✗ Branch 3 not taken.
31789033 bool wf = _walkflag(wx,wy,cnt,SWITCHBLOCK_STATE);
20517
20518
6/6
✓ Branch 0 taken 15283996 times.
✓ Branch 1 taken 16505037 times.
✓ Branch 2 taken 14832503 times.
✓ Branch 3 taken 451493 times.
✓ Branch 4 taken 6357215 times.
✓ Branch 5 taken 8475288 times.
31789033 if(isdungeon() && currscr<128 && !get_qr(qr_FREEFORM))
20519 {
20520
3/6
✓ Branch 0 taken 8475288 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8475288 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8475288 times.
8475288 if((diagonalMovement||NO_GRIDLOCK))
20521 {
20522 if(wx>=112&&wx<120&&wy<40&&wy>=32) wf=true;
20523
20524 if(wx>=136&&wx<144&&wy<40&&wy>=32) wf=true;
20525 }
20526 8475288 }
20527 //All problems related to exiting water are probably here. -Z
20528
3/4
✓ Branch 0 taken 31111703 times.
✓ Branch 1 taken 677330 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111703 times.
31789033 if(action==swimming || IsSideSwim())
20529 {
20530
2/2
✓ Branch 0 taken 645181 times.
✓ Branch 1 taken 32149 times.
677330 if(!wf)
20531 {
20532 32149 bool isthissolid = false;
20533
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 32149 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32149 times.
✓ Branch 4 taken 5887 times.
✓ Branch 5 taken 26262 times.
38460 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
20534
4/6
✓ Branch 0 taken 25838 times.
✓ Branch 1 taken 6311 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6311 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6311 times.
32149 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
20535
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 6289 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6289 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6289 times.
6311 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
20536
4/6
✓ Branch 0 taken 402 times.
✓ Branch 1 taken 5887 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5887 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5887 times.
32551 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
20537 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
20538
20539
20540
5/6
✓ Branch 0 taken 7310 times.
✓ Branch 1 taken 24839 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7310 times.
✓ Branch 4 taken 14729 times.
✓ Branch 5 taken 46086 times.
56988 if(landswim>= (get_qr(qr_DROWN) && isSwimming() ? 1
20541
2/2
✓ Branch 0 taken 2107 times.
✓ Branch 1 taken 22732 times.
24839 : (!diagonalMovement) ? 1 : (get_qr(qr_NO_HOPPING)?1:22)))
20542 {
20543 //Check for out of bounds for swimming
20544 14729 bool changehop = true;
20545
20546
5/6
✓ Branch 0 taken 1828 times.
✓ Branch 1 taken 12901 times.
✓ Branch 2 taken 1828 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12828 times.
✓ Branch 5 taken 11732 times.
14729 if((diagonalMovement||NO_GRIDLOCK))
20547 {
20548
2/4
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73 times.
25729 if(wx<0||wy<0)
20549 changehop = false;
20550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 else if(wx>248)
20551 changehop = false;
20552
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
73 else if(wx>240&&cnt==2)
20553 changehop = false;
20554
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 3 times.
73 else if(wy>168)
20555 3 changehop = false;
20556 73 }
20557
3/4
✓ Branch 0 taken 1901 times.
✓ Branch 1 taken 9904 times.
✓ Branch 2 taken 11805 times.
✗ Branch 3 not taken.
11805 if ((get_qr(qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) changehop = false;
20558 //This may be where the hang-up for exiting water exists. -Z
20559 // hop out of the water
20560
2/2
✓ Branch 0 taken 9907 times.
✓ Branch 1 taken 1898 times.
11805 if(changehop)
20561 1898 ret.setHopClk(1);
20562 11805 }
20563 else
20564 {
20565
6/6
✓ Branch 0 taken 26109 times.
✓ Branch 1 taken 19977 times.
✓ Branch 2 taken 25289 times.
✓ Branch 3 taken 20797 times.
✓ Branch 4 taken 16813 times.
✓ Branch 5 taken 8476 times.
46086 if((!(get_qr(qr_NO_HOPPING) || CanSideSwim()) || isthissolid) && (dir==d2 || shiftdir==d2))
20566 {
20567 //int32_t vx=((int32_t)x+4)&0xFFF8;
20568 //int32_t vy=((int32_t)y+4)&0xFFF8;
20569
2/2
✓ Branch 0 taken 1936 times.
✓ Branch 1 taken 7515 times.
25289 if(d2==left)
20570 {
20571
4/4
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1656 times.
✓ Branch 3 taken 280 times.
3596 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?6:11)), currmap, currscr, -1, x-1,y+(bigHitbox?6:11)) &&
20572
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1658 times.
1660 !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?9:12)), currmap, currscr, -1, x-1,y+(bigHitbox?9:12)) &&
20573
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1658 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1658 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1656 times.
1658 !_walkflag(x-1,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
20574
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1656 times.
1656 !_walkflag(x-1,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
20575 {
20576 1656 ret.setHopDir(d2);
20577 1656 ret.setIlswim(true);
20578 1656 }
20579 280 else ret.setIlswim(false);
20580 1936 }
20581
2/2
✓ Branch 0 taken 5751 times.
✓ Branch 1 taken 1764 times.
7515 else if(d2==right)
20582 {
20583
4/4
✓ Branch 0 taken 1654 times.
✓ Branch 1 taken 4097 times.
✓ Branch 2 taken 1654 times.
✓ Branch 3 taken 4097 times.
7405 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?6:11)), currmap, currscr, -1, x+16,y+(bigHitbox?6:11)) &&
20584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1654 times.
1654 !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?9:12)), currmap, currscr, -1, x+16,y+(bigHitbox?9:12)) &&
20585
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1654 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1654 times.
1654 !_walkflag(x+16,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
20586
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1654 times.
1654 !_walkflag(x+16,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
20587 {
20588 1654 ret.setHopDir(d2);
20589 1654 ret.setIlswim(true);
20590 1654 }
20591 4097 else ret.setIlswim(false);
20592 5751 }
20593
2/2
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 762 times.
1764 else if(d2==up)
20594 {
20595
4/4
✓ Branch 0 taken 541 times.
✓ Branch 1 taken 221 times.
✓ Branch 2 taken 539 times.
✓ Branch 3 taken 223 times.
1303 if(!iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1) &&
20596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 541 times.
541 !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1) &&
20597
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 541 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 541 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 539 times.
541 !_walkflag(x+7,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
20598
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 539 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 539 times.
539 !_walkflag(x+8,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
20599 {
20600 539 ret.setHopDir(d2);
20601 539 ret.setIlswim(true);
20602 539 }
20603 223 else ret.setIlswim(false);
20604 762 }
20605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1002 times.
1002 else if(d2==down)
20606 {
20607
4/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 651 times.
✓ Branch 2 taken 351 times.
✓ Branch 3 taken 651 times.
1353 if(!iswaterex(MAPCOMBO(x+7,y+16), currmap, currscr, -1, x+7,y+16) &&
20608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
351 !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16) &&
20609
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 351 times.
351 !_walkflag(x+7,y+16,1,SWITCHBLOCK_STATE) &&
20610
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 !_walkflag(x+8,y+16,1,SWITCHBLOCK_STATE))
20611 {
20612 351 ret.setHopDir(d2);
20613 351 ret.setIlswim(true);
20614 351 }
20615 651 else ret.setIlswim(false);
20616 1002 }
20617 9451 }
20618
20619
2/4
✓ Branch 0 taken 30248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30248 times.
30248 if(wx<0||wy<0);
20620
2/2
✓ Branch 0 taken 4422 times.
✓ Branch 1 taken 25826 times.
30248 else if(wx>248);
20621
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25826 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25826 else if(wx>240&&cnt==2);
20622
2/2
✓ Branch 0 taken 774 times.
✓ Branch 1 taken 25052 times.
25826 else if(wy>168);
20623
4/4
✓ Branch 0 taken 6428 times.
✓ Branch 1 taken 18624 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 6399 times.
25052 else if(get_qr(qr_DROWN) && !ilswim);
20624 //if(iswaterex(MAPCOMBO(wx,wy)) && iswaterex(MAPCOMBO(wx,wy)))
20625
2/2
✓ Branch 0 taken 17095 times.
✓ Branch 1 taken 1558 times.
18653 else if(iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
20626 {
20627 1558 ret.setUnwalkable(false);
20628 1558 return ret;
20629 }
20630 else
20631 {
20632 17095 ret.setUnwalkable(true);
20633 17095 return ret;
20634 }
20635 }
20636 23400 }
20637 else
20638 {
20639 645181 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
20640 645181 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Is x + 8 intentional???
20641
20642
8/8
✓ Branch 0 taken 595014 times.
✓ Branch 1 taken 50167 times.
✓ Branch 2 taken 537287 times.
✓ Branch 3 taken 57727 times.
✓ Branch 4 taken 50167 times.
✓ Branch 5 taken 57727 times.
✓ Branch 6 taken 39371 times.
✓ Branch 7 taken 10796 times.
645181 if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
20643 {
20644 576658 ret.setUnwalkable(false);
20645 576658 return ret;
20646 }
20647 }
20648 91923 }
20649
2/2
✓ Branch 0 taken 384504 times.
✓ Branch 1 taken 30727199 times.
31111703 else if(ladderx+laddery) // ladder is being used
20650 {
20651
8/10
✓ Branch 0 taken 27069 times.
✓ Branch 1 taken 357435 times.
✓ Branch 2 taken 25080 times.
✓ Branch 3 taken 1989 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1989 times.
✓ Branch 6 taken 1989 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1936 times.
✓ Branch 9 taken 53 times.
384504 int32_t lx = !(get_qr(qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wx) : x;
20652
8/10
✓ Branch 0 taken 27069 times.
✓ Branch 1 taken 357435 times.
✓ Branch 2 taken 25080 times.
✓ Branch 3 taken 1989 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1989 times.
✓ Branch 6 taken 1989 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1936 times.
✓ Branch 9 taken 53 times.
384504 int32_t ly = !(get_qr(qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wy) : y;
20653
20654
4/6
✓ Branch 0 taken 363296 times.
✓ Branch 1 taken 21208 times.
✓ Branch 2 taken 363296 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 363296 times.
384504 if((diagonalMovement||NO_GRIDLOCK))
20655 {
20656
2/2
✓ Branch 0 taken 13575 times.
✓ Branch 1 taken 7633 times.
21208 if(ladderdir==up)
20657 {
20658
2/2
✓ Branch 0 taken 3363 times.
✓ Branch 1 taken 4270 times.
7633 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
20659 {
20660 4270 bool temp = false;
20661
20662
2/2
✓ Branch 0 taken 1391 times.
✓ Branch 1 taken 2879 times.
4270 if(!(abs(lx-(ladderx+8))<=8))
20663 2879 temp = true;
20664
20665
2/2
✓ Branch 0 taken 3290 times.
✓ Branch 1 taken 980 times.
4270 if(cnt==2)
20666
1/2
✓ Branch 0 taken 980 times.
✗ Branch 1 not taken.
980 if(!(abs((lx+8)-(ladderx+8))<=8))
20667 temp=true;
20668
20669
2/2
✓ Branch 0 taken 2879 times.
✓ Branch 1 taken 1391 times.
4270 if(!temp)
20670 {
20671 1391 ret.setUnwalkable(false);
20672 1391 return ret;
20673 }
20674
20675
5/6
✓ Branch 0 taken 2879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2125 times.
✓ Branch 3 taken 754 times.
✓ Branch 4 taken 122 times.
✓ Branch 5 taken 2757 times.
2879 if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
20676 {
20677 2757 ret.setUnwalkable(true);
20678 2757 return ret;
20679 }
20680 122 }
20681 3485 }
20682 else
20683 {
20684
2/2
✓ Branch 0 taken 7020 times.
✓ Branch 1 taken 6555 times.
13575 if(abs(lx-(ladderx+8))<=8)
20685 {
20686
2/2
✓ Branch 0 taken 4323 times.
✓ Branch 1 taken 2232 times.
6555 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
20687 {
20688 4323 ret.setUnwalkable(false);
20689 4323 return ret;
20690 }
20691
20692
6/6
✓ Branch 0 taken 2220 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1785 times.
✓ Branch 3 taken 435 times.
✓ Branch 4 taken 916 times.
✓ Branch 5 taken 869 times.
2232 if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
20693 {
20694 1351 ret.setUnwalkable(true);
20695 1351 return ret;
20696 }
20697
20698
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 841 times.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
881 if((abs(ly-laddery+8)<=8) && d2<=down)
20699 {
20700 ret.setUnwalkable(false);
20701 return ret;
20702 }
20703 881 }
20704 }
20705 11386 } // diagonalMovement
20706 else
20707 {
20708
2/2
✓ Branch 0 taken 222358 times.
✓ Branch 1 taken 140938 times.
363296 if((d2&2)==ladderdir) // same direction
20709 {
20710
3/3
✓ Branch 0 taken 13729 times.
✓ Branch 1 taken 196539 times.
✓ Branch 2 taken 12090 times.
222358 switch(d2)
20711 {
20712 case up:
20713
2/2
✓ Branch 0 taken 8605 times.
✓ Branch 1 taken 3485 times.
12090 if(y.getInt()<=laddery)
20714 {
20715
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8605 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8605 times.
✓ Branch 4 taken 970 times.
✓ Branch 5 taken 7635 times.
16240 ret.setUnwalkable(_walkflag(ladderx,laddery-8,1,SWITCHBLOCK_STATE) ||
20716
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7635 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7635 times.
7635 _walkflag(ladderx+8,laddery-8,1,SWITCHBLOCK_STATE));
20717 8605 return ret;
20718
20719 }
20720
20721 [[fallthrough]];
20722 case down:
20723
2/2
✓ Branch 0 taken 9176 times.
✓ Branch 1 taken 8038 times.
17214 if((wy&0xF0)==laddery)
20724 {
20725 9176 ret.setUnwalkable(false);
20726 9176 return ret;
20727 }
20728
20729 8038 break;
20730
20731 default:
20732
2/2
✓ Branch 0 taken 74354 times.
✓ Branch 1 taken 122185 times.
196539 if((wx&0xF0)==ladderx)
20733 {
20734 74354 ret.setUnwalkable(false);
20735 74354 return ret;
20736 }
20737 122185 }
20738
20739
2/2
✓ Branch 0 taken 8038 times.
✓ Branch 1 taken 122185 times.
130223 if(d2<=down)
20740 {
20741
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 8038 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8038 times.
✓ Branch 4 taken 1060 times.
✓ Branch 5 taken 6978 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6978 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 6978 times.
8038 ret.setUnwalkable(_walkflag(ladderx,wy,1,SWITCHBLOCK_STATE) || _walkflag(ladderx+8,wy,1,SWITCHBLOCK_STATE));
20742 8038 return ret;
20743 }
20744
20745
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 122185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122185 times.
✓ Branch 4 taken 29654 times.
✓ Branch 5 taken 92531 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 92531 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 92531 times.
122185 ret.setUnwalkable(_walkflag((wx&0xF0),wy,1,SWITCHBLOCK_STATE) || _walkflag((wx&0xF0)+8,wy,1,SWITCHBLOCK_STATE));
20746 122185 return ret;
20747 }
20748
20749 // different dir
20750
3/8
✓ Branch 0 taken 140509 times.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 140509 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
140938 if(current_item_power(itype_ladder)<2 && !(isSideViewHero() && (d2==left || d2==right)))
20751 {
20752 140509 ret.setUnwalkable(true);
20753 140509 return ret;
20754 }
20755
20756
5/6
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 372 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 352 times.
✓ Branch 5 taken 20 times.
429 if(wy>=laddery && wy<=laddery+16 && d2<=down)
20757 {
20758 20 ret.setUnwalkable(false);
20759 20 return ret;
20760 }
20761 }
20762 11795 }
20763
6/6
✓ Branch 0 taken 25449313 times.
✓ Branch 1 taken 5277886 times.
✓ Branch 2 taken 25139933 times.
✓ Branch 3 taken 309380 times.
✓ Branch 4 taken 6572239 times.
✓ Branch 5 taken 18567694 times.
30727199 else if(wf || isSideViewHero() || get_qr(qr_DROWN))
20764 {
20765 // see if it's a good spot for the ladder or for swimming
20766
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12159505 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12159505 times.
12159505 bool unwalkablex = _walkflag(wx,wy,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
20767
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12159505 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12159505 times.
12159505 bool unwalkablex8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE);
20768
20769
2/2
✓ Branch 0 taken 3561696 times.
✓ Branch 1 taken 8597809 times.
12159505 if(get_qr(qr_DROWN))
20770 {
20771 // Drowning changes the following attributes:
20772 // * Dangerous water is also walkable, so ignore the previous
20773 // definitions of unwalkablex and unwalkablex8.
20774 // * Instead, prevent the ladder from being used in the
20775 // one frame where Hero has landed on water before drowning.
20776 8597809 unwalkablex = unwalkablex8 = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
20777 8597809 }
20778
20779 // check if he can swim
20780
5/6
✓ Branch 0 taken 2403213 times.
✓ Branch 1 taken 9756292 times.
✓ Branch 2 taken 2400249 times.
✓ Branch 3 taken 2964 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2400249 times.
12159505 if(current_item(itype_flippers) && z==0 && fakez==0)
20781 {
20782 2400249 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
20783 2400249 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Still not sure if this should be x + 8...
20784
2/6
✓ Branch 0 taken 2400249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2400249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2400249 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & item_flag3))) //Don't swim if the water's required level is too high! -Dimi
20785 {
20786 //ladder ignores water combos that are now walkable thanks to flippers -DD
20787
2/2
✓ Branch 0 taken 13116 times.
✓ Branch 1 taken 2387133 times.
2400249 unwalkablex = unwalkablex && (!wtrx);
20788
2/2
✓ Branch 0 taken 1358805 times.
✓ Branch 1 taken 1041444 times.
2400249 unwalkablex8 = unwalkablex8 && (!wtrx8);
20789
20790
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2400187 times.
2400249 if(landswim >= 22)
20791 {
20792 62 ret.setHopClk(2);
20793 62 ret.setUnwalkable(false);
20794 62 return ret;
20795 }
20796
8/8
✓ Branch 0 taken 2102429 times.
✓ Branch 1 taken 297758 times.
✓ Branch 2 taken 17578 times.
✓ Branch 3 taken 2084851 times.
✓ Branch 4 taken 297758 times.
✓ Branch 5 taken 2084851 times.
✓ Branch 6 taken 1874 times.
✓ Branch 7 taken 295884 times.
2400187 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
20797 {
20798
4/6
✓ Branch 0 taken 12538 times.
✓ Branch 1 taken 6914 times.
✓ Branch 2 taken 12538 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12538 times.
19452 if(!(diagonalMovement||NO_GRIDLOCK))
20799 {
20800 12538 ret.setHopClk(2);
20801
20802
2/4
✓ Branch 0 taken 12538 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12538 times.
12538 if(charging || spins>5)
20803 {
20804 //if Hero is charging, he might be facing the wrong direction (we want him to
20805 //hop into the water, not in the facing direction)
20806 ret.setDir(d2);
20807 //moreover Hero can't charge in the water -DD
20808 ret.setChargeAttack();
20809 }
20810
20811 12538 ret.setUnwalkable(false);
20812 12538 return ret;
20813 }
20814
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 6391 times.
6914 else if(dir==d2)
20815 {
20816 6391 ret.setIlswim(true);
20817 6391 ladderx = 0;
20818 6391 laddery = 0;
20819 6391 }
20820 6914 }
20821 2387649 }
20822 2387649 }
20823
20824 // check if he can use the ladder
20825 // "Allow Ladder Anywhere" is toggled by fLADDER
20826
2/2
✓ Branch 0 taken 9296679 times.
✓ Branch 1 taken 2850226 times.
12146905 if(can_deploy_ladder())
20827 // laddersetup
20828 {
20829 // Check if there's water to use the ladder over
20830 2850226 bool wtrx = (iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy) != 0);
20831 2850226 bool wtrx8 = (iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy) != 0);
20832 2850226 int32_t ldrid = current_item_id(itype_ladder);
20833
1/2
✓ Branch 0 taken 2850226 times.
✗ Branch 1 not taken.
2850226 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&item_flag1);
20834
20835
4/4
✓ Branch 0 taken 2840313 times.
✓ Branch 1 taken 9913 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 2840260 times.
2850226 if(wtrx || wtrx8)
20836 {
20837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9966 times.
9966 if(isSideViewHero())
20838 {
20839 wtrx = !_walkflag(wx, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
20840 wtrx8 = !_walkflag(wx+8, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx+8, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
20841 }
20842 // * walk on half-water using the ladder instead of using flippers.
20843 // * otherwise, walk on ladder(+hookshot) combos.
20844
3/8
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 9371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9966 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(wx, wy)) || isstepable(MAPCOMBO(wx+8,wy)) || wtrx==true))
20845 {
20846
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 464 times.
595 if(!get_qr(qr_OLD_210_WATER))
20847 {
20848 //if Hero could swim on a tile instead of using the ladder,
20849 //refuse to use the ladder to step over that tile. -DD
20850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 464 times.
464 wtrx = isstepable(MAPCOMBO(wx, wy)) && unwalkablex;
20851
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 458 times.
464 wtrx8 = isstepable(MAPCOMBO(wx+8,wy)) && unwalkablex8;
20852 464 }
20853 595 }
20854 9966 }
20855 else
20856 {
20857 // No water; check other things
20858
20859 //Check pits
20860
2/2
✓ Branch 0 taken 2839233 times.
✓ Branch 1 taken 1027 times.
2840260 if(ladderpits)
20861 {
20862 1027 int32_t pit_cmb = getpitfall(wx,wy);
20863
1/2
✓ Branch 0 taken 1027 times.
✗ Branch 1 not taken.
1027 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
20864 1027 pit_cmb = getpitfall(x+8,wy);
20865
1/2
✓ Branch 0 taken 1027 times.
✗ Branch 1 not taken.
1027 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
20866 1027 }
20867
4/6
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 2839233 times.
✓ Branch 2 taken 1027 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1027 times.
✗ Branch 5 not taken.
2840260 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
20868 {
20869 2840260 int32_t combo=combobuf[MAPCOMBO(wx, wy)].type;
20870
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 2840074 times.
2840260 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
20871 2840260 combo=combobuf[MAPCOMBO(wx+8, wy)].type;
20872
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 2839968 times.
2840260 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
20873 2840260 }
20874 }
20875
20876
2/2
✓ Branch 0 taken 5700452 times.
✓ Branch 1 taken 2850226 times.
8550678 for (int32_t i = 0; i <= 1; ++i)
20877 {
20878
2/2
✓ Branch 0 taken 4345824 times.
✓ Branch 1 taken 1354628 times.
5700452 if(tmpscr2[i].valid!=0)
20879 {
20880
2/2
✓ Branch 0 taken 1303366 times.
✓ Branch 1 taken 51262 times.
1354628 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20881 {
20882
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1303366 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1303366 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && !_walkflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
20883
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1303366 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1303366 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && !_walkflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
20884 1303366 }
20885 else
20886 {
20887
3/4
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 51003 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 259 times.
51262 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && _effectflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
20888
3/4
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 51025 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 237 times.
51262 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && _effectflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
20889 }
20890 1354628 }
20891 5700452 }
20892
2/2
✓ Branch 0 taken 2062592 times.
✓ Branch 1 taken 787634 times.
2850226 bool walkwater = (get_qr(qr_DROWN) && !iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy));
20893
20894
4/6
✓ Branch 0 taken 2202554 times.
✓ Branch 1 taken 647672 times.
✓ Branch 2 taken 2202554 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2202554 times.
2850226 if((diagonalMovement||NO_GRIDLOCK))
20895 {
20896
2/2
✓ Branch 0 taken 109936 times.
✓ Branch 1 taken 537736 times.
647672 if(d2==dir)
20897 {
20898 537736 int32_t c = walkwater ? 0:8;
20899 537736 int32_t b = walkwater ? 8:0;
20900
20901
2/2
✓ Branch 0 taken 347962 times.
✓ Branch 1 taken 189774 times.
537736 if(d2>=left)
20902 {
20903 // If the difference between wy and y is small enough
20904
4/4
✓ Branch 0 taken 102382 times.
✓ Branch 1 taken 245580 times.
✓ Branch 2 taken 347804 times.
✓ Branch 3 taken 158 times.
347962 if(abs((wy)-(int32_t(y+c)))<=(b) && wtrx)
20905 {
20906 // Don't activate the ladder if it would be entirely
20907 // over water and Hero has the flippers. This isn't
20908 // a good way to do this, but it's too risky
20909 // to make big changes to this stuff.
20910 158 bool deployLadder=true;
20911 158 int32_t lx=wx&0xF0;
20912
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 156 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 156 times.
✓ Branch 7 taken 2 times.
158 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
20913 {
20914
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
20915 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
20916 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
20917 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
20918 deployLadder=false;
20919 2 }
20920
1/2
✓ Branch 0 taken 158 times.
✗ Branch 1 not taken.
158 if(deployLadder)
20921 {
20922 158 ladderx = wx&0xF0;
20923 158 laddery = y;
20924 158 ladderdir = left;
20925 158 ladderstart = d2;
20926 158 ret.setUnwalkable(laddery!=y.getInt());
20927 158 return ret;
20928 }
20929 }
20930 347804 }
20931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189774 times.
189774 else if(d2<=down)
20932 {
20933 // If the difference between wx and x is small enough
20934
4/4
✓ Branch 0 taken 75665 times.
✓ Branch 1 taken 114109 times.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 189687 times.
189774 if(abs((wx)-(int32_t(x+c)))<=(b) && wtrx)
20935 {
20936 87 ladderx = x;
20937 87 laddery = wy&0xF0;
20938 87 ladderdir = up;
20939 87 ladderstart = d2;
20940 87 ret.setUnwalkable(ladderx!=x.getInt());
20941 87 return ret;
20942 }
20943
20944
2/2
✓ Branch 0 taken 75624 times.
✓ Branch 1 taken 114063 times.
189687 if(cnt==2)
20945 {
20946
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114063 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 114046 times.
114063 if(abs((wx+8)-(int32_t(x+c)))<=(b) && wtrx8)
20947 {
20948 17 ladderx = x;
20949 17 laddery = wy&0xF0;
20950 17 ladderdir = up;
20951 17 ladderstart = d2;
20952 17 ret.setUnwalkable(ladderx!=x.getInt());
20953 17 return ret;
20954 }
20955 114046 }
20956 189670 }
20957 537474 }
20958 647410 }
20959 else
20960 {
20961
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2202554 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2202554 times.
✓ Branch 4 taken 116610 times.
✓ Branch 5 taken 2085944 times.
2202554 bool flgx = _walkflag(wx,wy,1,SWITCHBLOCK_STATE) && !wtrx; // Solid, and not steppable
20962
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2202554 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2202554 times.
✓ Branch 4 taken 2015835 times.
✓ Branch 5 taken 186719 times.
2202554 bool flgx8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE) && !wtrx8; // Solid, and not steppable
20963
20964
2/2
✓ Branch 0 taken 2039953 times.
✓ Branch 1 taken 162601 times.
2202626 if((d2>=left && wtrx)
20965 // Deploy the ladder vertically even if Hero is only half on water.
20966
8/8
✓ Branch 0 taken 18496 times.
✓ Branch 1 taken 2021457 times.
✓ Branch 2 taken 162601 times.
✓ Branch 3 taken 2021457 times.
✓ Branch 4 taken 1222 times.
✓ Branch 5 taken 161379 times.
✓ Branch 6 taken 72 times.
✓ Branch 7 taken 162529 times.
2202554 || (d2<=down && ((wtrx && !flgx8) || (wtrx8 && !flgx))))
20967 {
20968
4/4
✓ Branch 0 taken 17936 times.
✓ Branch 1 taken 560 times.
✓ Branch 2 taken 697 times.
✓ Branch 3 taken 17239 times.
18496 if(((y.getInt()+15) < wy) || ((y.getInt()+8) > wy))
20969 1257 ladderdir = up;
20970 else
20971 17239 ladderdir = left;
20972
20973
2/2
✓ Branch 0 taken 17239 times.
✓ Branch 1 taken 1257 times.
18496 if(ladderdir==up)
20974 {
20975 1257 ladderx = x.getInt()&0xF8;
20976 1257 laddery = wy&0xF0;
20977 1257 }
20978 else
20979 {
20980 17239 ladderx = wx&0xF0;
20981 17239 laddery = y.getInt()&0xF8;
20982 }
20983
20984 18496 ret.setUnwalkable(false);
20985 18496 return ret;
20986 }
20987 }
20988 2831468 }
20989 12128147 }
20990
20991 30799559 ret.setUnwalkable(wf);
20992 30799559 return ret;
20993 32272740 }
20994
20995 // Only checks for moving blocks. Apparently this is a thing we need.
20996 3040076 HeroClass::WalkflagInfo HeroClass::walkflagMBlock(int32_t wx,int32_t wy)
20997 {
20998 3040076 HeroClass::WalkflagInfo ret;
20999
2/2
✓ Branch 0 taken 47377 times.
✓ Branch 1 taken 2992699 times.
3040076 if (!mblock2.active()) //Without this, weird swimming behaviors happen.
21000 {
21001 2992699 ret.setFlags(~1);
21002 2992699 ret.setHopDir(-1);
21003 2992699 }
21004
2/2
✓ Branch 0 taken 2807 times.
✓ Branch 1 taken 3037269 times.
3040076 if(toogam) return ret;
21005
2/2
✓ Branch 0 taken 2989892 times.
✓ Branch 1 taken 47377 times.
3037269 if (mblock2.active())
21006 47377 ret.setUnwalkable(mblock2.hit(wx,wy,0,1,1,1));
21007
2/2
✓ Branch 0 taken 3037019 times.
✓ Branch 1 taken 250 times.
3037269 if (collide_object(wx, wy,1, 1))
21008 250 ret.setUnwalkable(true);
21009 3037269 return ret;
21010 3040076 }
21011
21012 13985763 bool HeroClass::checksoliddamage()
21013 {
21014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13985763 times.
13985763 if(toogam) return false;
21015
21016
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13985763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13985763 if (get_qr(qr_NO_SIDEVIEW_SOLID_DAMAGE) && get_qr(qr_NOSOLIDDAMAGECOMBOS)) return false; //no point checking if both of these rules are on
21017
21018
2/4
✓ Branch 0 taken 13985763 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13985763 times.
13985763 if(z!=0||fakez!=0) return false;
21019 13985763 int32_t bx = x.getInt();
21020 13985763 int32_t by = y.getInt();
21021 13985763 int32_t initk = 0;
21022
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3454335 times.
✓ Branch 2 taken 2804005 times.
✓ Branch 3 taken 3738302 times.
✓ Branch 4 taken 3989121 times.
13985763 switch(dir)
21023 {
21024 case up:
21025
21026
2/2
✓ Branch 0 taken 83482 times.
✓ Branch 1 taken 3370853 times.
3454335 by-=get_qr(qr_NEW_HERO_MOVEMENT2)?(bigHitbox ? 4 : -4):(bigHitbox ? 1 : -7);
21027
2/2
✓ Branch 0 taken 83482 times.
✓ Branch 1 taken 3370853 times.
3454335 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) bx += 8;
21028
1/2
✓ Branch 0 taken 3370853 times.
✗ Branch 1 not taken.
3370853 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) bx += 4;
21029
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 3454235 times.
3454335 if(by<0)
21030 {
21031 100 return false;
21032 }
21033 3454235 break;
21034
21035 case down:
21036
21037 2804005 by+=get_qr(qr_NEW_HERO_MOVEMENT2)?16:20;
21038
2/2
✓ Branch 0 taken 89712 times.
✓ Branch 1 taken 2714293 times.
2804005 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) bx += 8;
21039
1/2
✓ Branch 0 taken 2714293 times.
✗ Branch 1 not taken.
2714293 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) bx += 4;
21040
2/2
✓ Branch 0 taken 26492 times.
✓ Branch 1 taken 2777513 times.
2804005 if(by>175)
21041 {
21042 26492 return false;
21043 }
21044
21045 2777513 break;
21046
21047 case left:
21048 3738302 bx-=get_qr(qr_NEW_HERO_MOVEMENT2)?1:4;
21049
2/2
✓ Branch 0 taken 119761 times.
✓ Branch 1 taken 3618541 times.
3738302 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) by += bigHitbox?7:11;
21050
1/2
✓ Branch 0 taken 3618541 times.
✗ Branch 1 not taken.
3618541 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) by += 4;
21051
4/4
✓ Branch 0 taken 3670090 times.
✓ Branch 1 taken 68212 times.
✓ Branch 2 taken 119761 times.
✓ Branch 3 taken 3550329 times.
3738302 if (!bigHitbox && !get_qr(qr_LENIENT_SOLID_DAMAGE))
21052 {
21053 3550329 by+=8;
21054 3550329 initk = 1;
21055 3550329 }
21056
2/2
✓ Branch 0 taken 20307 times.
✓ Branch 1 taken 3717995 times.
3738302 if(bx<0)
21057 {
21058 20307 return false;
21059 }
21060
21061 3717995 break;
21062
21063 case right:
21064 3989121 bx+=get_qr(qr_NEW_HERO_MOVEMENT2)?16:20;
21065
2/2
✓ Branch 0 taken 118008 times.
✓ Branch 1 taken 3871113 times.
3989121 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) by += bigHitbox?7:11;
21066
1/2
✓ Branch 0 taken 3871113 times.
✗ Branch 1 not taken.
3871113 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) by += 4;
21067
4/4
✓ Branch 0 taken 3911527 times.
✓ Branch 1 taken 77594 times.
✓ Branch 2 taken 118008 times.
✓ Branch 3 taken 3793519 times.
3989121 if (!bigHitbox && !get_qr(qr_LENIENT_SOLID_DAMAGE))
21068 {
21069 3793519 by+=8;
21070 3793519 initk = 1;
21071 3793519 }
21072
2/2
✓ Branch 0 taken 28669 times.
✓ Branch 1 taken 3960452 times.
3989121 if(bx>255)
21073 {
21074 28669 return false;
21075 }
21076
21077 3960452 break;
21078 }
21079
2/2
✓ Branch 0 taken 13499522 times.
✓ Branch 1 taken 410673 times.
13910195 if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) initk++;
21080 13910195 newcombo const& cmb = combobuf[MAPCOMBO(bx,by)];
21081 13910195 int32_t t = cmb.type;
21082
2/2
✓ Branch 0 taken 13910079 times.
✓ Branch 1 taken 116 times.
13910195 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
21083 116 t = cNONE;
21084 13910195 int32_t initbx = bx;
21085 13910195 int32_t initby = by;
21086
21087 // Unlike push blocks, damage combos should be tested on layers 2 and under
21088
2/2
✓ Branch 0 taken 25272069 times.
✓ Branch 1 taken 13910180 times.
39182249 for(int32_t i=(get_qr(qr_DMGCOMBOLAYERFIX) ? 2 : 0); i>=0; i--)
21089 {
21090 25272069 bx = initbx;
21091 25272069 by = initby;
21092
2/2
✓ Branch 0 taken 7733665 times.
✓ Branch 1 taken 17538404 times.
25272069 if (!get_qr(qr_NOSOLIDDAMAGECOMBOS))
21093 {
21094
2/2
✓ Branch 0 taken 16306377 times.
✓ Branch 1 taken 41550590 times.
57856967 for (int32_t k = initk; k <= 2; k++)
21095 {
21096 41550590 newcombo const& cmb = combobuf[FFCore.tempScreens[i]->data[COMBOPOS(bx,by)]];
21097 41550590 t = cmb.type;
21098
2/2
✓ Branch 0 taken 41550272 times.
✓ Branch 1 taken 318 times.
41550590 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
21099 318 t = cNONE;
21100 // Solid damage combos use pushing>0, hence the code is here.
21101
9/10
✓ Branch 0 taken 1851423 times.
✓ Branch 1 taken 39699167 times.
✓ Branch 2 taken 80484 times.
✓ Branch 3 taken 1770939 times.
✓ Branch 4 taken 77595 times.
✓ Branch 5 taken 2889 times.
✓ Branch 6 taken 1593 times.
✓ Branch 7 taken 76002 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1593 times.
41550590 if (!get_qr(qr_LESS_AWFUL_SIDESPIKES) || !isSideViewHero() || (dir != down && (dir != up || getOnSideviewLadder())))
21102 {
21103
13/16
✓ Branch 0 taken 41517787 times.
✓ Branch 1 taken 28321 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28321 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28321 times.
✓ Branch 6 taken 1265 times.
✓ Branch 7 taken 27056 times.
✓ Branch 8 taken 169 times.
✓ Branch 9 taken 1096 times.
✓ Branch 10 taken 67 times.
✓ Branch 11 taken 102 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 67 times.
✓ Branch 14 taken 41546041 times.
✓ Branch 15 taken 67 times.
41546108 if(combo_class_buf[t].modify_hp_amount && _walkflag(bx,by,1,SWITCHBLOCK_STATE) && pushing>0 && hclk<1 && action!=casting && action != sideswimcasting)
21104 {
21105 // Bite Hero
21106
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 8 times.
67 if (checkdamagecombos(bx, bx, by, by, i-1, true)) return true;
21107 59 }
21108 41546100 }
21109
2/2
✓ Branch 0 taken 22331792 times.
✓ Branch 1 taken 19218790 times.
41550582 if (dir < left) bx += (k % 2) ? 7 : 8;
21110 19218790 else by += (k % 2) ? 7 : 8;
21111
2/2
✓ Branch 0 taken 40318563 times.
✓ Branch 1 taken 1232019 times.
41550582 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) break;
21112 40318563 }
21113 17538396 }
21114
4/6
✓ Branch 0 taken 383790 times.
✓ Branch 1 taken 24888271 times.
✓ Branch 2 taken 383790 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 356865 times.
25628926 if(isSideViewHero() && !get_qr(qr_NO_SIDEVIEW_SOLID_DAMAGE) && // Check for sideview damage combos
21115
3/4
✓ Branch 0 taken 356865 times.
✓ Branch 1 taken 26925 times.
✓ Branch 2 taken 356865 times.
✗ Branch 3 not taken.
383790 hclk<1 && action!=casting && action!=sideswimcasting) // ... but only if Hero could be hurt
21116 {
21117
2/2
✓ Branch 0 taken 37353 times.
✓ Branch 1 taken 319512 times.
356865 if (get_qr(qr_LESS_AWFUL_SIDESPIKES))
21118 {
21119
2/6
✓ Branch 0 taken 37353 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37353 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37353 if (on_sideview_solid_oldpos(this) && (!getOnSideviewLadder() || DrunkDown()))
21120 {
21121
4/4
✓ Branch 0 taken 37349 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 37351 times.
✓ Branch 3 taken 2 times.
37353 if(checkdamagecombos(x+4, x+4, y+16, y+18, i-1, false, false) && checkdamagecombos(x+12, x+12, y+16, y+18, i-1, false, false))
21122 {
21123
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (checkdamagecombos(x+4, x+12, y+16, y+18, i-1, false, true)) return true;
21124 }
21125 37351 }
21126
1/2
✓ Branch 0 taken 37351 times.
✗ Branch 1 not taken.
37351 if (checkdamagecombos(x+4, x+12, y+8, y+15, i-1, false, true)) return true;
21127 37351 }
21128 else
21129 {
21130 //old 2.50.2-ish code for 2.50.0 sideview quests for er_OLDSIDEVIEWSPIKES
21131
1/2
✓ Branch 0 taken 319512 times.
✗ Branch 1 not taken.
319512 if ( get_qr(qr_OLDSIDEVIEWSPIKES ) )
21132 {
21133
2/2
✓ Branch 0 taken 319507 times.
✓ Branch 1 taken 5 times.
639024 if (checkdamagecombos(x+8-(zfix)(tmpscr->csensitive),
21134
1/2
✓ Branch 0 taken 319512 times.
✗ Branch 1 not taken.
319512 x+8+(zc_max(tmpscr->csensitive-1,0)),
21135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 319512 times.
319512 y+17-(get_qr(qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2),
21136
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 319512 times.
✓ Branch 2 taken 319512 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 319512 times.
319512 y+17+zc_max((get_qr(qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2)-1,0), i-1, true))
21137 5 return true;
21138 319507 }
21139 else //2.50.1 and later
21140 {
21141 if(checkdamagecombos(x+4, x+12, y+16, y+24))
21142 return true;
21143 }
21144 }
21145
21146 356858 }
21147 25272054 }
21148 13910180 return false;
21149 13985763 }
21150 14146038 void HeroClass::checkpushblock()
21151 {
21152
2/2
✓ Branch 0 taken 14694 times.
✓ Branch 1 taken 14131344 times.
14146038 if(toogam) return;
21153
21154
3/4
✓ Branch 0 taken 14112704 times.
✓ Branch 1 taken 18640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14112704 times.
14131344 if(z!=0||fakez!=0) return;
21155
21156 // Return early in some cases..
21157 14112704 bool earlyReturn=false;
21158
21159
5/6
✓ Branch 0 taken 9721570 times.
✓ Branch 1 taken 4391134 times.
✓ Branch 2 taken 9721570 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10919735 times.
✓ Branch 5 taken 3192969 times.
14112704 if(!(diagonalMovement||NO_GRIDLOCK) || dir==left)
21160
2/2
✓ Branch 0 taken 3855601 times.
✓ Branch 1 taken 7064134 times.
10919735 if(x.getInt()&15) earlyReturn=true;
21161
21162 // if(y<16) return;
21163
4/4
✓ Branch 0 taken 255615 times.
✓ Branch 1 taken 13857089 times.
✓ Branch 2 taken 128674 times.
✓ Branch 3 taken 126941 times.
14112704 if(isSideViewHero() && !on_sideview_solid_oldpos(this)) return;
21164
21165 13985763 int32_t bx = x.getInt()&0xF0;
21166 13985763 int32_t by = (y.getInt()&0xF0);
21167
21168
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3454335 times.
✓ Branch 2 taken 2804005 times.
✓ Branch 3 taken 3738302 times.
✓ Branch 4 taken 3989121 times.
13985763 switch(dir)
21169 {
21170 case up:
21171
2/2
✓ Branch 0 taken 118437 times.
✓ Branch 1 taken 3335898 times.
3454335 if(y<16)
21172 {
21173 118437 earlyReturn=true;
21174 118437 break;
21175 }
21176
21177
3/4
✓ Branch 0 taken 580241 times.
✓ Branch 1 taken 2755657 times.
✓ Branch 2 taken 580241 times.
✗ Branch 3 not taken.
3335898 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
21178
21179
2/2
✓ Branch 0 taken 1931726 times.
✓ Branch 1 taken 1404172 times.
3335898 if((int32_t)x&8) bx+=16;
21180
21181 3335898 break;
21182
21183 case down:
21184
2/2
✓ Branch 0 taken 231879 times.
✓ Branch 1 taken 2572126 times.
2804005 if(y>128)
21185 {
21186 231879 earlyReturn=true;
21187 231879 break;
21188 }
21189 else
21190 {
21191 2572126 by+=16;
21192
21193
2/2
✓ Branch 0 taken 1649335 times.
✓ Branch 1 taken 922791 times.
2572126 if((int32_t)x&8) bx+=16;
21194 }
21195
21196 2572126 break;
21197
21198 case left:
21199
2/2
✓ Branch 0 taken 196528 times.
✓ Branch 1 taken 3541774 times.
3738302 if(x<32)
21200 {
21201 196528 earlyReturn=true;
21202 196528 break;
21203 }
21204 else
21205 {
21206 3541774 bx-=16;
21207
21208
2/2
✓ Branch 0 taken 2141757 times.
✓ Branch 1 taken 1400017 times.
3541774 if(y.getInt()&8)
21209 {
21210 1400017 by+=16;
21211 1400017 }
21212 }
21213
21214 3541774 break;
21215
21216 case right:
21217
2/2
✓ Branch 0 taken 205036 times.
✓ Branch 1 taken 3784085 times.
3989121 if(x>208)
21218 {
21219 205036 earlyReturn=true;
21220 205036 break;
21221 }
21222 else
21223 {
21224 3784085 bx+=16;
21225
21226
2/2
✓ Branch 0 taken 2305002 times.
✓ Branch 1 taken 1479083 times.
3784085 if(y.getInt()&8)
21227 {
21228 1479083 by+=16;
21229 1479083 }
21230 }
21231
21232 3784085 break;
21233 }
21234
21235
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 13985748 times.
13985763 if (checksoliddamage()) return;
21236
21237
2/2
✓ Branch 0 taken 7365557 times.
✓ Branch 1 taken 6620191 times.
13985748 if(earlyReturn)
21238 7365557 return;
21239
21240 6620191 int itemid=current_item_id(itype_bracelet);
21241 6620191 size_t combopos = (by&0xF0)+(bx>>4);
21242
2/2
✓ Branch 0 taken 2764201 times.
✓ Branch 1 taken 3855990 times.
6620191 bool limitedpush = (itemid>=0 && itemsbuf[itemid].flags & item_flag1);
21243
2/2
✓ Branch 0 taken 3855990 times.
✓ Branch 1 taken 2764201 times.
6620191 itemdata const* glove = itemid < 0 ? NULL : &itemsbuf[itemid];
21244
2/2
✓ Branch 0 taken 1712241 times.
✓ Branch 1 taken 10056286 times.
11768527 for(int lyr = 2; lyr > -1; --lyr) //Top-down, in case of stacked push blocks
21245 {
21246
4/4
✓ Branch 0 taken 6359589 times.
✓ Branch 1 taken 3696697 times.
✓ Branch 2 taken 1457097 times.
✓ Branch 3 taken 4902492 times.
10056286 if(get_qr(qr_HESITANTPUSHBLOCKS)&&(pushing<4)) break;
21247
4/4
✓ Branch 0 taken 3435391 times.
✓ Branch 1 taken 1718403 times.
✓ Branch 2 taken 89477 times.
✓ Branch 3 taken 3345914 times.
5153794 if(lyr && !get_qr(qr_PUSHBLOCK_LAYER_1_2))
21248 3345914 continue;
21249 1807880 cpos_info& cpinfo = cpos_get(lyr, combopos);
21250 1807880 mapscr* m = FFCore.tempScreens[lyr];
21251
2/2
✓ Branch 0 taken 90213 times.
✓ Branch 1 taken 1717667 times.
1807880 int cid = lyr == 0 ? MAPCOMBO(bx,by) : MAPCOMBOL(lyr,bx,by);
21252 1807880 newcombo const& cmb = combobuf[cid];
21253 1807880 int f = MAPFLAG2(lyr-1,bx,by);
21254 1807880 int f2 = cmb.flag;
21255 1807880 int t = cmb.type;
21256
21257
6/6
✓ Branch 0 taken 1692278 times.
✓ Branch 1 taken 115602 times.
✓ Branch 2 taken 1687745 times.
✓ Branch 3 taken 4533 times.
✓ Branch 4 taken 2464 times.
✓ Branch 5 taken 1685281 times.
3493161 bool waitblock = (t==cPUSH_WAIT || t==cPUSH_HW || t==cPUSH_HW2) ||
21258
2/2
✓ Branch 0 taken 1684419 times.
✓ Branch 1 taken 862 times.
1685281 (t == cPUSHBLOCK && (cmb.usrflags&cflag6));
21259 1807880 int heavy = 0;
21260
4/4
✓ Branch 0 taken 1802611 times.
✓ Branch 1 taken 5269 times.
✓ Branch 2 taken 15029 times.
✓ Branch 3 taken 1787582 times.
1807880 if(t==cPUSH_HW || t==cPUSH_HEAVY)
21261 20298 heavy = 1;
21262
4/4
✓ Branch 0 taken 1783685 times.
✓ Branch 1 taken 3897 times.
✓ Branch 2 taken 2464 times.
✓ Branch 3 taken 1781221 times.
1787582 else if(t==cPUSH_HEAVY2 || t==cPUSH_HW2)
21263 6361 heavy = 2;
21264
2/2
✓ Branch 0 taken 1780359 times.
✓ Branch 1 taken 862 times.
1781221 else if(t == cPUSHBLOCK)
21265 862 heavy = cmb.attribytes[0];
21266
21267
6/6
✓ Branch 0 taken 121863 times.
✓ Branch 1 taken 1686017 times.
✓ Branch 2 taken 39413 times.
✓ Branch 3 taken 82450 times.
✓ Branch 4 taken 3708 times.
✓ Branch 5 taken 35705 times.
1807880 if(waitblock && (pushing<16 || hasMainGuy())) continue;
21268
21269
8/8
✓ Branch 0 taken 1700263 times.
✓ Branch 1 taken 21459 times.
✓ Branch 2 taken 18606 times.
✓ Branch 3 taken 2853 times.
✓ Branch 4 taken 3028 times.
✓ Branch 5 taken 15578 times.
✓ Branch 6 taken 6256 times.
✓ Branch 7 taken 1715466 times.
1758759 if(heavy && (itemid<0 || glove->power < heavy ||
21270
3/4
✓ Branch 0 taken 12678 times.
✓ Branch 1 taken 2900 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2900 times.
21834 (limitedpush && usecounts[itemid] >= zc_max(1, glove->misc3)))) continue;
21271
21272 1715466 bool doit=false;
21273 1715466 bool changecombo=false;
21274
21275 1715466 int blockdir = dir;
21276
1/2
✓ Branch 0 taken 1715466 times.
✗ Branch 1 not taken.
1715466 if(blockdir > 3) blockdir = Y_DIR(dir);
21277
6/6
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 1714604 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 83 times.
✓ Branch 4 taken 476 times.
✓ Branch 5 taken 303 times.
1715466 if(t == cPUSHBLOCK && (get_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING) || (f!=mfPUSHED)))
21278 {
21279
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 181 times.
✓ Branch 3 taken 191 times.
✓ Branch 4 taken 123 times.
559 switch(blockdir)
21280 {
21281 case up:
21282 64 doit = cmb.usrflags & cflag1;
21283 64 break;
21284 case down:
21285 181 doit = cmb.usrflags & cflag2;
21286 181 break;
21287 case left:
21288 191 doit = cmb.usrflags & cflag3;
21289 191 break;
21290 case right:
21291 123 doit = cmb.usrflags & cflag4;
21292 123 break;
21293 }
21294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(cmb.usrflags & cflag5) //Separate directions
21295 {
21296 if(int limit = cmb.attribytes[4+blockdir])
21297 {
21298 if(cpinfo.pushes[blockdir] >= limit)
21299 doit = false;
21300 }
21301 else if(cmb.usrflags & cflag9)
21302 doit = false;
21303 }
21304 else
21305 {
21306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(int limit = cmb.attribytes[4])
21307 {
21308 if(cpinfo.sumpush() >= limit)
21309 doit = false;
21310 }
21311
1/2
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
559 else if(cmb.usrflags & cflag9)
21312 doit = false;
21313 }
21314 559 }
21315 else
21316 {
21317
2/2
✓ Branch 0 taken 1706463 times.
✓ Branch 1 taken 8444 times.
1714907 if(is_push_flag(f,dir))
21318 {
21319 8444 doit=true;
21320 8444 }
21321
21322
7/8
✓ Branch 0 taken 1714171 times.
✓ Branch 1 taken 736 times.
✓ Branch 2 taken 1714171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✓ Branch 5 taken 1714447 times.
✓ Branch 6 taken 1713652 times.
✓ Branch 7 taken 519 times.
3428618 if((((f2==mfPUSHUD || f2==mfPUSHUDNS|| f2==mfPUSHUDINS) && dir<=down) ||
21323
3/4
✓ Branch 0 taken 1714159 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 1714159 times.
✗ Branch 3 not taken.
1714447 ((f2==mfPUSHLR || f2==mfPUSHLRNS|| f2==mfPUSHLRINS) && dir>=left) ||
21324
3/4
✓ Branch 0 taken 1714159 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 1714159 times.
✗ Branch 3 not taken.
1714447 ((f2==mfPUSHU || f2==mfPUSHUNS || f2==mfPUSHUINS) && dir==up) ||
21325
3/4
✓ Branch 0 taken 1713845 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 1713845 times.
✗ Branch 3 not taken.
1713891 ((f2==mfPUSHD || f2==mfPUSHDNS || f2==mfPUSHDINS) && dir==down) ||
21326
3/4
✓ Branch 0 taken 1713790 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 1713790 times.
✗ Branch 3 not taken.
1713857 ((f2==mfPUSHL || f2==mfPUSHLNS || f2==mfPUSHLINS) && dir==left) ||
21327
3/4
✓ Branch 0 taken 1713784 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 1713784 times.
✗ Branch 3 not taken.
1713857 ((f2==mfPUSHR || f2==mfPUSHRNS || f2==mfPUSHRINS) && dir==right) ||
21328
2/2
✓ Branch 0 taken 1713457 times.
✓ Branch 1 taken 254 times.
1714171 f2==mfPUSH4 || f2==mfPUSH4NS || f2==mfPUSH4INS)&&(f!=mfPUSHED))
21329 {
21330 519 changecombo=true;
21331 519 doit=true;
21332 519 }
21333 }
21334
21335
2/2
✓ Branch 0 taken 881423 times.
✓ Branch 1 taken 833307 times.
1714730 if(get_qr(qr_SOLIDBLK))
21336 {
21337
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 242532 times.
✓ Branch 2 taken 203014 times.
✓ Branch 3 taken 169447 times.
✓ Branch 4 taken 218314 times.
833307 switch(blockdir)
21338 {
21339 case up:
21340
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 242532 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 242532 times.
✓ Branch 4 taken 144628 times.
✓ Branch 5 taken 97904 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 97904 times.
✓ Branch 8 taken 144636 times.
✓ Branch 9 taken 97896 times.
242532 if(_walkflag(bx,by-8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE)) doit=false;
21341
21342 242532 break;
21343
21344 case down:
21345
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 203014 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 203014 times.
✓ Branch 4 taken 111338 times.
✓ Branch 5 taken 91676 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 91676 times.
✓ Branch 8 taken 111348 times.
✓ Branch 9 taken 91666 times.
203014 if(_walkflag(bx,by+24,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE)) doit=false;
21346
21347 203014 break;
21348
21349 case left:
21350
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 169447 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 169447 times.
✓ Branch 4 taken 76058 times.
✓ Branch 5 taken 93389 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 93389 times.
✓ Branch 8 taken 76074 times.
✓ Branch 9 taken 93373 times.
169447 if(_walkflag(bx-16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE)) doit=false;
21351
21352 169447 break;
21353
21354 case right:
21355
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 218314 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 218314 times.
✓ Branch 4 taken 99252 times.
✓ Branch 5 taken 119062 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 119062 times.
✓ Branch 8 taken 99299 times.
✓ Branch 9 taken 119015 times.
218314 if(_walkflag(bx+16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE)) doit=false;
21356
21357 218314 break;
21358 }
21359 833307 }
21360
21361
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 607783 times.
✓ Branch 2 taken 501275 times.
✓ Branch 3 taken 276003 times.
✓ Branch 4 taken 329669 times.
1714730 switch(blockdir)
21362 {
21363 case up:
21364
4/4
✓ Branch 0 taken 606543 times.
✓ Branch 1 taken 1240 times.
✓ Branch 2 taken 340 times.
✓ Branch 3 taken 606203 times.
607783 if((MAPFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS)) doit=false;
21365
21366 607783 break;
21367
21368 case down:
21369
4/4
✓ Branch 0 taken 500035 times.
✓ Branch 1 taken 1240 times.
✓ Branch 2 taken 378 times.
✓ Branch 3 taken 499657 times.
501275 if((MAPFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS)) doit=false;
21370
21371 501275 break;
21372
21373 case left:
21374
4/4
✓ Branch 0 taken 275127 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 274917 times.
276003 if((MAPFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS)) doit=false;
21375
21376 276003 break;
21377
21378 case right:
21379
4/4
✓ Branch 0 taken 328325 times.
✓ Branch 1 taken 1344 times.
✓ Branch 2 taken 377 times.
✓ Branch 3 taken 327948 times.
329669 if((MAPFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS)) doit=false;
21380
21381 329669 break;
21382 }
21383
21384
2/2
✓ Branch 0 taken 1710008 times.
✓ Branch 1 taken 4722 times.
1714730 if(doit)
21385 {
21386
2/2
✓ Branch 0 taken 4669 times.
✓ Branch 1 taken 53 times.
4722 if(limitedpush)
21387 53 ++usecounts[itemid];
21388
21389 // for(int32_t i=0; i<1; i++)
21390
2/2
✓ Branch 0 taken 657 times.
✓ Branch 1 taken 4065 times.
4722 if(!mblock2.active())
21391 {
21392
2/2
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 3602 times.
4065 if(is_push_flag(f,dir))
21393 {
21394 3602 m->sflag[combopos]=0;
21395 3602 }
21396
21397 4065 mblock2.blockLayer = lyr;
21398
21399
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 3860 times.
4065 if(t == cPUSHBLOCK)
21400 {
21401 205 zfix blockstep = 0.5;
21402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(cmb.attrishorts[0] > 0)
21403 205 blockstep = zslongToFix(cmb.attrishorts[0]*100);
21404 205 mblock2.push_new(zfix(bx),zfix(by),blockdir,f,blockstep);
21405 205 mblock2.blockinfo = cpinfo;
21406 205 mblock2.blockinfo.push(blockdir, cmb.usrflags&cflag8);
21407 205 cpinfo.clearInfo();
21408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(cmb.attribytes[1])
21409 205 sfx(cmb.attribytes[1],(int32_t)x);
21410 205 }
21411 else
21412 {
21413 3860 mblock2.push((zfix)bx,(zfix)by,blockdir,f);
21414
21415
2/2
✓ Branch 0 taken 1052 times.
✓ Branch 1 taken 2808 times.
3860 if(get_qr(qr_MORESOUNDS))
21416 1052 sfx(WAV_ZN1PUSHBLOCK,(int32_t)x);
21417 }
21418 4065 }
21419 4722 break;
21420 }
21421 1710008 }
21422 14145302 }
21423
21424 847 bool usekey()
21425 {
21426 847 int32_t itemid = current_item_id(itype_magickey);
21427
21428
3/4
✓ Branch 0 taken 787 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
847 if(itemid<0 ||
21429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 (itemsbuf[itemid].flags & item_flag1 ? itemsbuf[itemid].power<dlevel
21430 : itemsbuf[itemid].power!=dlevel))
21431 {
21432
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 668 times.
787 if(game->lvlkeys[dlevel]!=0)
21433 {
21434 119 game->lvlkeys[dlevel]--;
21435 //run script for level key item
21436 119 int32_t key_item = 0; //current_item_id(itype_lkey); //not possible
21437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9065 times.
9065 for ( int32_t q = 0; q < MAXITEMS; ++q )
21438 {
21439
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 119 times.
9065 if ( itemsbuf[q].family == itype_lkey )
21440 {
21441 119 key_item = q; break;
21442 }
21443 8946 }
21444
21445
2/8
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
119 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21446 {
21447 int i = key_item;
21448 FFCore.reset_script_engine_data(ScriptType::Item, i);
21449 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21450 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
21451 }
21452 119 return true;
21453 }
21454 else
21455 {
21456
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 332 times.
668 if(game->get_keys()==0)
21457 {
21458 332 return false;
21459 }
21460 else
21461 {
21462 //run script for key item
21463 336 int32_t key_item = 0; //current_item_id(itype_key); //not possible
21464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360 times.
3360 for ( int32_t q = 0; q < MAXITEMS; ++q )
21465 {
21466
2/2
✓ Branch 0 taken 3024 times.
✓ Branch 1 taken 336 times.
3360 if ( itemsbuf[q].family == itype_key )
21467 {
21468 336 key_item = q; break;
21469 }
21470 3024 }
21471
2/8
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 336 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
336 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21472 {
21473 int i = key_item;
21474 FFCore.reset_script_engine_data(ScriptType::Item, i);
21475 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21476 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
21477 }
21478 336 game->change_keys(-1);
21479 }
21480 }
21481 336 }
21482
21483 396 return true;
21484 847 }
21485
21486 11 bool canUseKey(int32_t num)
21487 {
21488 11 int32_t itemid = current_item_id(itype_magickey);
21489
21490
1/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(itemid<0 ||
21491 (itemsbuf[itemid].flags & item_flag1 ? itemsbuf[itemid].power<dlevel
21492 : itemsbuf[itemid].power!=dlevel))
21493 {
21494 11 return game->lvlkeys[dlevel] + game->get_keys() >= num;
21495 }
21496
21497 return true;
21498 11 }
21499
21500 11 bool usekey(int32_t num)
21501 {
21502
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
11 if(!canUseKey(num)) return false;
21503
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 for(auto q = 0; q < num; ++q)
21504 {
21505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!usekey()) return false; //should never return false here, but, just to be safe....
21506 8 }
21507 8 return true;
21508 11 }
21509
21510
21511 1262 bool islockeddoor(int32_t x, int32_t y, int32_t lock)
21512 {
21513 1262 int32_t mc = (y&0xF0)+(x>>4);
21514
4/6
✓ Branch 0 taken 1262 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1262 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1176 times.
✓ Branch 5 taken 86 times.
2524 bool ret = (((mc==7||mc==8||mc==23||mc==24) && tmpscr->door[up]==lock)
21515
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1262 times.
✓ Branch 2 taken 1262 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1262 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1262 times.
✗ Branch 7 not taken.
1262 || ((mc==151||mc==152||mc==167||mc==168) && tmpscr->door[down]==lock)
21516
3/6
✓ Branch 0 taken 1262 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1262 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1262 times.
✗ Branch 5 not taken.
1262 || ((mc==64||mc==65||mc==80||mc==81) && tmpscr->door[left]==lock)
21517
5/8
✓ Branch 0 taken 1253 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 1253 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1253 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1253 times.
1262 || ((mc==78||mc==79||mc==94||mc==95) && tmpscr->door[right]==lock));
21518 1262 return ret;
21519 }
21520
21521 13581125 void HeroClass::oldchecklockblock()
21522 {
21523
2/2
✓ Branch 0 taken 14355 times.
✓ Branch 1 taken 13566770 times.
13581125 if(toogam) return;
21524
21525 13566770 int32_t bx = x.getInt()&0xF0;
21526 13566770 int32_t bx2 = int32_t(x+8)&0xF0;
21527 13566770 int32_t by = y.getInt()&0xF0;
21528
21529
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3356291 times.
✓ Branch 2 taken 2693583 times.
✓ Branch 3 taken 3630160 times.
✓ Branch 4 taken 3886736 times.
13566770 switch(dir)
21530 {
21531 case up:
21532
4/4
✓ Branch 0 taken 581547 times.
✓ Branch 1 taken 2774744 times.
✓ Branch 2 taken 11800 times.
✓ Branch 3 taken 569747 times.
3356291 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
21533
21534 3356291 break;
21535
21536 case down:
21537 2693583 by+=16;
21538 2693583 break;
21539
21540 case left:
21541
2/2
✓ Branch 0 taken 1602869 times.
✓ Branch 1 taken 2027291 times.
3630160 if((((int32_t)x)&0x0F)<8)
21542 2027291 bx-=16;
21543
21544
2/2
✓ Branch 0 taken 2223695 times.
✓ Branch 1 taken 1406465 times.
3630160 if(y.getInt()&8)
21545 {
21546 1406465 by+=16;
21547 1406465 }
21548
21549 3630160 bx2=bx;
21550 3630160 break;
21551
21552 case right:
21553 3886736 bx+=16;
21554
21555
2/2
✓ Branch 0 taken 2390832 times.
✓ Branch 1 taken 1495904 times.
3886736 if(y.getInt()&8)
21556 {
21557 1495904 by+=16;
21558 1495904 }
21559
21560 3886736 bx2=bx;
21561 3886736 break;
21562 }
21563
21564 13566770 bool found1=false;
21565 13566770 bool found2=false;
21566 13566770 int32_t foundlayer = -1;
21567 13566770 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
21568 13566770 newcombo const& cmb = combobuf[cid1];
21569 13566770 newcombo const& cmb2 = combobuf[cid2];
21570
4/6
✓ Branch 0 taken 2512 times.
✓ Branch 1 taken 13564258 times.
✓ Branch 2 taken 2512 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2512 times.
13566770 if((cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1)))
21571 {
21572 // Context: https://discord.com/channels/876899628556091432/1278165595321405554
21573 // Layer 0 is overridden by Locked Doors (but only for dungeons) - in that case, checklocked will clear these combos
21574
2/2
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 919 times.
2512 bool ignore_layer_0 = isdungeon() && islockeddoor(bx,by,dLOCKED);
21575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2512 times.
2512 if (!ignore_layer_0)
21576 {
21577 2512 found1=true;
21578 2512 foundlayer = 0;
21579 2512 }
21580 2512 }
21581
4/6
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 13564053 times.
✓ Branch 2 taken 205 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 205 times.
13564258 else if (cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, -1))
21582 {
21583
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 bool ignore_layer_0 = isdungeon() && islockeddoor(bx2,by,dLOCKED);
21584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if (!ignore_layer_0)
21585 {
21586 205 found2=true;
21587 205 foundlayer = 0;
21588 205 }
21589 205 }
21590
21591
2/2
✓ Branch 0 taken 27133540 times.
✓ Branch 1 taken 13566770 times.
40700310 for (int32_t i = 0; i <= 1; ++i)
21592 {
21593
2/2
✓ Branch 0 taken 20053641 times.
✓ Branch 1 taken 7079899 times.
27133540 if(tmpscr2[i].valid!=0)
21594 {
21595
2/2
✓ Branch 0 taken 6719162 times.
✓ Branch 1 taken 360737 times.
7079899 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21596 {
21597
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6719162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6719162 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
21598
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6719162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6719162 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
21599 6719162 }
21600 else
21601 {
21602
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 359372 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
360737 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
21603
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 359372 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
360737 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
21604 }
21605 7079899 }
21606 27133540 }
21607
21608
21609 // Layers
21610
4/4
✓ Branch 0 taken 13564258 times.
✓ Branch 1 taken 2512 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 13564053 times.
13566770 if(!(found1 || found2))
21611 {
21612 13564053 foundlayer = -1;
21613
2/2
✓ Branch 0 taken 13563968 times.
✓ Branch 1 taken 27128072 times.
40692040 for(int32_t i=0; i<2; i++)
21614 {
21615 27128072 cid1 = MAPCOMBO2(i, bx, by);
21616 27128072 cid2 = MAPCOMBO2(i, bx2, by);
21617 27128072 newcombo const& cmb = combobuf[cid1];
21618 27128072 newcombo const& cmb2 = combobuf[cid2];
21619
2/2
✓ Branch 0 taken 13564019 times.
✓ Branch 1 taken 13564053 times.
27128072 if (i == 0)
21620 {
21621
2/2
✓ Branch 0 taken 11685217 times.
✓ Branch 1 taken 1878836 times.
13564053 if(tmpscr2[1].valid!=0)
21622 {
21623
2/2
✓ Branch 0 taken 1756772 times.
✓ Branch 1 taken 122064 times.
1878836 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21624 {
21625
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1756772 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1756772 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue; //Continue, because It didn't find any on layer 0, and if you're checking
21626
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1756772 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1756772 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue; //layer 1 and there's a bridge on layer 2, stop checking layer 1.
21627 1756772 }
21628 else
21629 {
21630
3/4
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 121612 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 452 times.
122064 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
21631
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 121612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
121612 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
21632 }
21633 1878384 }
21634 13563601 }
21635
4/6
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 27127538 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 82 times.
27127620 if(cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
21636 {
21637 82 found1=true;
21638 82 foundlayer = i+1;
21639 //zprint("Found layer: %d \n", i);
21640 82 break;
21641 }
21642
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 27127535 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
27127538 else if(cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, i))
21643 {
21644 3 found2=true;
21645 3 foundlayer = i+1;
21646 //zprint("Found layer: %d \n", i);
21647 3 break;
21648 }
21649 27127535 }
21650 13564053 }
21651
21652
4/4
✓ Branch 0 taken 13564176 times.
✓ Branch 1 taken 2594 times.
✓ Branch 2 taken 13566370 times.
✓ Branch 3 taken 400 times.
13566770 if(!(found1 || found2) || pushing<8)
21653 {
21654 13566370 return;
21655 }
21656
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 51 times.
400 newcombo const& cmb3 = combobuf[found1 ? cid1 : cid2];
21657
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 262 times.
400 if(!try_locked_combo(cmb3))
21658 262 return;
21659
21660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(cmb.usrflags&cflag16)
21661 {
21662 setxmapflag(1<<cmb.attribytes[5]);
21663 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
21664 }
21665 else
21666 {
21667 138 setmapflag(mLOCKBLOCK);
21668 138 remove_lockblocks((currscr>=128)?1:0);
21669 }
21670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if ( cmb3.usrflags&cflag3 )
21671 {
21672 if ( (cmb3.attribytes[3]) )
21673 sfx(cmb3.attribytes[3]);
21674 }
21675 138 else sfx(WAV_DOOR);
21676 13581125 }
21677
21678 13581125 void HeroClass::oldcheckbosslockblock()
21679 {
21680
2/2
✓ Branch 0 taken 14355 times.
✓ Branch 1 taken 13566770 times.
13581125 if(toogam) return;
21681
21682 13566770 int32_t bx = x.getInt()&0xF0;
21683 13566770 int32_t bx2 = int32_t(x+8)&0xF0;
21684 13566770 int32_t by = y.getInt()&0xF0;
21685
21686
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3356291 times.
✓ Branch 2 taken 2693583 times.
✓ Branch 3 taken 3630160 times.
✓ Branch 4 taken 3886736 times.
13566770 switch(dir)
21687 {
21688 case up:
21689
4/4
✓ Branch 0 taken 581547 times.
✓ Branch 1 taken 2774744 times.
✓ Branch 2 taken 11800 times.
✓ Branch 3 taken 569747 times.
3356291 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
21690
21691 3356291 break;
21692
21693 case down:
21694 2693583 by+=16;
21695 2693583 break;
21696
21697 case left:
21698
2/2
✓ Branch 0 taken 1602869 times.
✓ Branch 1 taken 2027291 times.
3630160 if((((int32_t)x)&0x0F)<8)
21699 2027291 bx-=16;
21700
21701
2/2
✓ Branch 0 taken 2223695 times.
✓ Branch 1 taken 1406465 times.
3630160 if(y.getInt()&8)
21702 {
21703 1406465 by+=16;
21704 1406465 }
21705
21706 3630160 bx2=bx;
21707 3630160 break;
21708
21709 case right:
21710 3886736 bx+=16;
21711
21712
2/2
✓ Branch 0 taken 2390832 times.
✓ Branch 1 taken 1495904 times.
3886736 if(y.getInt()&8)
21713 {
21714 1495904 by+=16;
21715 1495904 }
21716
21717 3886736 bx2=bx;
21718 3886736 break;
21719 }
21720
21721
21722 13566770 bool found1 = false;
21723 13566770 bool found2 = false;
21724 13566770 int32_t foundlayer = -1;
21725 13566770 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
21726 13566770 newcombo const& cmb = combobuf[cid1];
21727 13566770 newcombo const& cmb2 = combobuf[cid2];
21728
21729
4/6
✓ Branch 0 taken 1327 times.
✓ Branch 1 taken 13565443 times.
✓ Branch 2 taken 1327 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1327 times.
13566770 if((cmb.type==cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1)))
21730 {
21731 // Context: https://discord.com/channels/876899628556091432/1278165595321405554
21732 // Layer 0 is overridden by Locked Doors (but only for dungeons) - in that case, checklocked will clear these combos
21733
2/2
✓ Branch 0 taken 1006 times.
✓ Branch 1 taken 321 times.
1327 bool ignore_layer_0 = isdungeon() && islockeddoor(bx,by,dBOSS);
21734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1327 times.
1327 if (!ignore_layer_0)
21735 {
21736 1327 found1=true;
21737 1327 foundlayer = 0;
21738 1327 }
21739 1327 }
21740
4/6
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 13565412 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 31 times.
13565443 else if (cmb2.type==cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, -1))
21741 {
21742
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 22 times.
31 bool ignore_layer_0 = isdungeon() && islockeddoor(bx2,by,dBOSS);
21743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (!ignore_layer_0)
21744 {
21745 31 found2=true;
21746 31 foundlayer = 0;
21747 31 }
21748 31 }
21749
21750
2/2
✓ Branch 0 taken 27133540 times.
✓ Branch 1 taken 13566770 times.
40700310 for (int32_t i = 0; i <= 1; ++i)
21751 {
21752
2/2
✓ Branch 0 taken 20053641 times.
✓ Branch 1 taken 7079899 times.
27133540 if (tmpscr2[i].valid != 0)
21753 {
21754
2/2
✓ Branch 0 taken 6719162 times.
✓ Branch 1 taken 360737 times.
7079899 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21755 {
21756
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6719162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6719162 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
21757
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6719162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6719162 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
21758 6719162 }
21759 else
21760 {
21761
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 359372 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
360737 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
21762
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 359372 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
360737 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
21763 }
21764 7079899 }
21765 27133540 }
21766
21767
21768 // Layers
21769
4/4
✓ Branch 0 taken 13565443 times.
✓ Branch 1 taken 1327 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 13565412 times.
13566770 if (!(found1 || found2))
21770 {
21771 13565412 foundlayer = -1;
21772
2/2
✓ Branch 0 taken 13565412 times.
✓ Branch 1 taken 27130824 times.
40696236 for (int32_t i = 0; i < 2; i++)
21773 {
21774 27130824 cid1 = MAPCOMBO2(i, bx, by);
21775 27130824 cid2 = MAPCOMBO2(i, bx2, by);
21776 27130824 newcombo const& cmb = combobuf[cid1];
21777 27130824 newcombo const& cmb2 = combobuf[cid2];
21778
2/2
✓ Branch 0 taken 13565412 times.
✓ Branch 1 taken 13565412 times.
27130824 if (i == 0)
21779 {
21780
2/2
✓ Branch 0 taken 11686224 times.
✓ Branch 1 taken 1879188 times.
13565412 if (tmpscr2[1].valid != 0)
21781 {
21782
2/2
✓ Branch 0 taken 1757060 times.
✓ Branch 1 taken 122128 times.
1879188 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21783 {
21784
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1757060 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1757060 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
21785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1757060 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1757060 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
21786 1757060 }
21787 else
21788 {
21789
3/4
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 121676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 452 times.
122128 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
21790
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 121676 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
121676 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
21791 }
21792 1878736 }
21793 13564960 }
21794
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27130372 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27130372 if (cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, i))
21795 {
21796 found1 = true;
21797 foundlayer = i;
21798 break;
21799 }
21800
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27130372 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27130372 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, i))
21801 {
21802 found2 = true;
21803 foundlayer = i;
21804 break;
21805 }
21806 27130372 }
21807 13565412 }
21808
21809
4/4
✓ Branch 0 taken 13565443 times.
✓ Branch 1 taken 1327 times.
✓ Branch 2 taken 13566299 times.
✓ Branch 3 taken 471 times.
13566770 if (!(found1 || found2) || pushing < 8)
21810 {
21811 13566299 return;
21812 }
21813
2/2
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 3 times.
471 int32_t cid = found1 ? cid1 : cid2;
21814
21815
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 436 times.
471 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
21816
21817
21818 // Run Boss Key Script
21819 35 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2380 times.
2380 for ( int32_t q = 0; q < MAXITEMS; ++q )
21821 {
21822
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 35 times.
2380 if ( itemsbuf[q].family == itype_bosskey )
21823 {
21824 35 key_item = q; break;
21825 }
21826 2345 }
21827
2/8
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
35 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21828 {
21829 int i = key_item;
21830 FFCore.reset_script_engine_data(ScriptType::Item, i);
21831 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21832 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
21833 }
21834
21835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(cmb.usrflags&cflag16)
21836 {
21837 setxmapflag(1<<cmb.attribytes[5]);
21838 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
21839 }
21840 else
21841 {
21842 35 setmapflag(mBOSSLOCKBLOCK);
21843 35 remove_bosslockblocks((currscr>=128)?1:0);
21844 }
21845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if ( (combobuf[cid].attribytes[3]) )
21846 35 sfx(combobuf[cid].attribytes[3]);
21847 13581125 }
21848
21849 39433320 void HeroClass::oldcheckchest(int32_t type)
21850 {
21851 // chests aren't affected by tmpscr->flags2&fAIRCOMBOS
21852
5/6
✓ Branch 0 taken 39393102 times.
✓ Branch 1 taken 40218 times.
✓ Branch 2 taken 39352353 times.
✓ Branch 3 taken 40749 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 39352353 times.
39433320 if(toogam || z>0 || fakez > 0) return;
21853
2/2
✓ Branch 0 taken 37749786 times.
✓ Branch 1 taken 1602567 times.
39352353 if(pushing<8) return;
21854 1602567 int32_t bx = x.getInt()&0xF0;
21855 1602567 int32_t bx2 = int32_t(x+8)&0xF0;
21856 1602567 int32_t by = y.getInt()&0xF0;
21857
21858
3/4
✓ Branch 0 taken 867771 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 339834 times.
✓ Branch 3 taken 394962 times.
1602567 switch(dir)
21859 {
21860 case up:
21861
2/2
✓ Branch 0 taken 40752 times.
✓ Branch 1 taken 354210 times.
394962 if(isSideViewHero()) return;
21862
21863
4/4
✓ Branch 0 taken 81006 times.
✓ Branch 1 taken 273204 times.
✓ Branch 2 taken 78609 times.
✓ Branch 3 taken 2397 times.
354210 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
21864
21865 354210 break;
21866
21867 case left:
21868 case right:
21869
2/2
✓ Branch 0 taken 16173 times.
✓ Branch 1 taken 851598 times.
867771 if(isSideViewHero()) break;
21870 [[fallthrough]];
21871 case down:
21872 1191432 return;
21873 }
21874
21875 370383 bool found=false;
21876 370383 bool itemflag=false;
21877
21878
3/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 370246 times.
✓ Branch 2 taken 137 times.
✗ Branch 3 not taken.
370418 if((combobuf[MAPCOMBO(bx,by)].type==type && _effectflag(bx,by,1, -1))||
21879
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 370211 times.
370246 (combobuf[MAPCOMBO(bx2,by)].type==type && _effectflag(bx2,by,1, -1)))
21880 {
21881 172 found=true;
21882 172 }
21883
2/2
✓ Branch 0 taken 740766 times.
✓ Branch 1 taken 370383 times.
1111149 for (int32_t i = 0; i <= 1; ++i)
21884 {
21885
2/2
✓ Branch 0 taken 571848 times.
✓ Branch 1 taken 168918 times.
740766 if(tmpscr2[i].valid!=0)
21886 {
21887
2/2
✓ Branch 0 taken 168057 times.
✓ Branch 1 taken 861 times.
168918 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21888 {
21889
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 168057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
168057 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
21890
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 168057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
168057 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
21891 168057 }
21892 else
21893 {
21894
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
21895
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
21896 }
21897 168918 }
21898 740766 }
21899
21900
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 370211 times.
370383 if(!found)
21901 {
21902
2/2
✓ Branch 0 taken 370211 times.
✓ Branch 1 taken 740422 times.
1110633 for(int32_t i=0; i<2; i++)
21903 {
21904
2/2
✓ Branch 0 taken 370211 times.
✓ Branch 1 taken 370211 times.
740422 if (i == 0)
21905 {
21906
2/2
✓ Branch 0 taken 335422 times.
✓ Branch 1 taken 34789 times.
370211 if(tmpscr2[1].valid!=0)
21907 {
21908
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 381 times.
34789 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21909 {
21910
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
34408 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
21911
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
34408 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
21912 34408 }
21913 else
21914 {
21915
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
21916
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
21917 }
21918 34789 }
21919 370211 }
21920
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 740422 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
740422 if((combobuf[MAPCOMBO2(i,bx,by)].type==type && _effectflag(bx,by,1, i))||
21921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 740422 times.
740422 (combobuf[MAPCOMBO2(i,bx2,by)].type==type && _effectflag(bx2,by,1, i)))
21922 {
21923 found=true;
21924 break;
21925 }
21926 740422 }
21927 370211 }
21928
21929
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 370211 times.
370383 if(!found)
21930 {
21931 370211 return;
21932 }
21933
21934
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 2 times.
172 switch(type)
21935 {
21936 case cLOCKEDCHEST:
21937
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 56 times.
69 if(!usekey()) return;
21938
21939 13 setmapflag(mLOCKEDCHEST);
21940 13 break;
21941
21942 case cCHEST:
21943 101 setmapflag(mCHEST);
21944 101 break;
21945
21946 case cBOSSCHEST:
21947
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
21948 // Run Boss Key Script
21949 2 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 for ( int32_t q = 0; q < MAXITEMS; ++q )
21951 {
21952
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 2 times.
136 if ( itemsbuf[q].family == itype_bosskey )
21953 {
21954 2 key_item = q; break;
21955 }
21956 134 }
21957
2/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21958 {
21959 int i = key_item;
21960 FFCore.reset_script_engine_data(ScriptType::Item, i);
21961 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21962 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
21963 }
21964 2 setmapflag(mBOSSCHEST);
21965 2 break;
21966 }
21967
21968 116 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
21969 116 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
21970 116 itemflag |= MAPFLAG(bx,by)==mfARMOS_ITEM;
21971 116 itemflag |= MAPFLAG(bx2,by)==mfARMOS_ITEM;
21972 116 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
21973 116 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
21974
21975
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!itemflag)
21976 {
21977 for(int32_t i=0; i<2; i++)
21978 {
21979 itemflag |= MAPFLAG2(i,bx,by)==mfARMOS_ITEM;
21980 itemflag |= MAPFLAG2(i,bx2,by)==mfARMOS_ITEM;
21981 itemflag |= MAPCOMBOFLAG2(i,bx,by)==mfARMOS_ITEM;
21982 itemflag |= MAPCOMBOFLAG2(i,bx2,by)==mfARMOS_ITEM;
21983 }
21984 }
21985
21986
3/6
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
116 if(itemflag && !getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM))
21987 {
21988
4/8
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 items.add(new item(x, y,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
21989 116 }
21990 39433320 }
21991
21992 4133956 void HeroClass::checkchest(int32_t type)
21993 {
21994
4/4
✓ Branch 0 taken 3132498 times.
✓ Branch 1 taken 1001458 times.
✓ Branch 2 taken 1001458 times.
✓ Branch 3 taken 2131040 times.
4133956 bool ischest = type == cCHEST || type == cLOCKEDCHEST || type == cBOSSCHEST;
21995
2/2
✓ Branch 0 taken 564791 times.
✓ Branch 1 taken 3569165 times.
4133956 bool islockblock = type == cLOCKBLOCK || type == cBOSSLOCKBLOCK;
21996
2/2
✓ Branch 0 taken 564791 times.
✓ Branch 1 taken 3569165 times.
4133956 bool islocked = type == cLOCKBLOCK || type == cLOCKEDCHEST;
21997
2/2
✓ Branch 0 taken 564791 times.
✓ Branch 1 taken 3569165 times.
4133956 bool isbosslocked = type == cBOSSLOCKBLOCK || type == cBOSSCHEST;
21998
2/2
✓ Branch 0 taken 1129582 times.
✓ Branch 1 taken 3004374 times.
4133956 if(ischest)
21999 {
22000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3004374 times.
3004374 if(get_qr(qr_OLD_CHEST_COLLISION))
22001 {
22002 oldcheckchest(type);
22003 return;
22004 }
22005 3004374 }
22006
3/4
✓ Branch 0 taken 1129582 times.
✓ Branch 1 taken 3004374 times.
✓ Branch 2 taken 1129582 times.
✗ Branch 3 not taken.
4133956 if(islockblock && get_qr(qr_OLD_LOCKBLOCK_COLLISION))
22007 {
22008 if(type == cLOCKBLOCK)
22009 oldchecklockblock();
22010 else if(type == cBOSSLOCKBLOCK)
22011 oldcheckbosslockblock();
22012 return;
22013 }
22014
5/6
✓ Branch 0 taken 4129414 times.
✓ Branch 1 taken 4542 times.
✓ Branch 2 taken 4107833 times.
✓ Branch 3 taken 21581 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4107833 times.
4133956 if(toogam || z>0 || fakez > 0) return;
22015 4107833 zfix bx, by;
22016 4107833 zfix bx2, by2;
22017 4107833 zfix fx(-1), fy(-1);
22018
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 894589 times.
✓ Branch 2 taken 903757 times.
✓ Branch 3 taken 1131460 times.
✓ Branch 4 taken 1178027 times.
4107833 switch(dir)
22019 {
22020 case up:
22021 894589 by = y + (bigHitbox ? -2 : 6);
22022 894589 by2 = by;
22023 894589 bx = x + 4;
22024 894589 bx2 = bx + 8;
22025 894589 break;
22026 case down:
22027 903757 by = y + 17;
22028 903757 by2 = by;
22029 903757 bx = x + 4;
22030 903757 bx2 = bx + 8;
22031 903757 break;
22032 case left:
22033 1131460 by = y + (bigHitbox ? 0 : 8);
22034 1131460 by2 = y + 8;
22035 1131460 bx = x - 2;
22036 1131460 bx2 = x - 2;
22037 1131460 break;
22038 case right:
22039 1178027 by = y + (bigHitbox ? 0 : 8);
22040 1178027 by2 = y + 8;
22041 1178027 bx = x + 17;
22042 1178027 bx2 = x + 17;
22043 1178027 break;
22044 }
22045
22046 4107833 int32_t found = -1;
22047 4107833 int32_t foundlayer = 0;
22048
22049 4107833 newcombo const* cmb = &combobuf[MAPCOMBO(bx,by)];
22050
22051
4/6
✓ Branch 0 taken 2434 times.
✓ Branch 1 taken 4105399 times.
✓ Branch 2 taken 2434 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2434 times.
4107833 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1))
22052 {
22053 2434 found = MAPCOMBO(bx,by);
22054 2434 fx = bx; fy = by;
22055
2/2
✓ Branch 0 taken 4868 times.
✓ Branch 1 taken 2434 times.
7302 for (int32_t i = 0; i <= 1; ++i)
22056 {
22057
2/2
✓ Branch 0 taken 1157 times.
✓ Branch 1 taken 3711 times.
4868 if(tmpscr2[i].valid!=0)
22058 {
22059
2/2
✓ Branch 0 taken 2714 times.
✓ Branch 1 taken 997 times.
3711 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22060 {
22061
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2714 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2714 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
22062 2714 }
22063 else
22064 {
22065
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 997 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
997 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
22066 }
22067 3711 }
22068 4868 }
22069 2434 }
22070
2/2
✓ Branch 0 taken 2434 times.
✓ Branch 1 taken 4105399 times.
4107833 if(found<0)
22071 {
22072 4105399 cmb = &combobuf[MAPCOMBO(bx2,by2)];
22073
4/6
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 4105323 times.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 76 times.
4105399 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, -1))
22074 {
22075 76 found = MAPCOMBO(bx2,by2);
22076
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 532 times.
608 for (int32_t i = 0; i <= 6; ++i)
22077 {
22078
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 212 times.
532 if(tmpscr2[i].valid!=0)
22079 {
22080
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 120 times.
212 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22081 {
22082
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
92 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i])))
22083 {
22084 found = -1;
22085 break;
22086 }
22087 92 }
22088 else
22089 {
22090
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i])))
22091 {
22092 found = -1;
22093 break;
22094 }
22095 }
22096 212 }
22097 532 }
22098
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(found != -1)
22099 {
22100 76 fx = bx2; fy = by2;
22101 76 }
22102 76 }
22103 4105399 }
22104
22105
2/2
✓ Branch 0 taken 2510 times.
✓ Branch 1 taken 4105323 times.
4107833 if(found<0)
22106 {
22107
2/2
✓ Branch 0 taken 4105124 times.
✓ Branch 1 taken 24630943 times.
28736067 for(int32_t i=0; i<6; i++)
22108 {
22109 24630943 cmb = &combobuf[MAPCOMBO2(i,bx,by)];
22110
4/6
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 24630744 times.
✓ Branch 2 taken 199 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 199 times.
24630943 if(combobuf[MAPCOMBO2(i,bx,by)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
22111 {
22112 199 found = MAPCOMBO2(i,bx,by);
22113
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 995 times.
1194 for(int32_t j = i+1; j < 6; ++j)
22114 {
22115
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 245 times.
995 if (tmpscr2[j].valid!=0)
22116 {
22117
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 139 times.
245 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22118 {
22119
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
106 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[j])))
22120 {
22121 found = -1;
22122 break;
22123 }
22124 106 }
22125 else
22126 {
22127
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[j])))
22128 {
22129 found = -1;
22130 break;
22131 }
22132 }
22133 245 }
22134 995 }
22135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199 times.
199 if(found>-1)
22136 {
22137 199 foundlayer = i+1;
22138 199 fx = bx; fy = by;
22139 199 break;
22140 }
22141 }
22142 24630744 cmb = &combobuf[MAPCOMBO2(i,bx2,by2)];
22143
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24630744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24630744 if(combobuf[MAPCOMBO2(i,bx2,by2)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, i))
22144 {
22145 found = MAPCOMBO2(i,bx2,by2);
22146 for(int32_t j = i+1; j < 6; ++j)
22147 {
22148 if (tmpscr2[j].valid!=0)
22149 {
22150 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22151 {
22152 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[j])))
22153 {
22154 found = -1;
22155 break;
22156 }
22157 }
22158 else
22159 {
22160 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[j])))
22161 {
22162 found = -1;
22163 break;
22164 }
22165 }
22166 }
22167 }
22168 if(found>-1)
22169 {
22170 foundlayer = i+1;
22171 fx = bx2; fy = by2;
22172 break;
22173 }
22174 }
22175 24630744 }
22176 4105323 }
22177
22178
2/2
✓ Branch 0 taken 2709 times.
✓ Branch 1 taken 4105124 times.
4107833 if(found<0) return;
22179 2709 cmb = &combobuf[found];
22180
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2531 times.
✓ Branch 2 taken 78 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 78 times.
2709 switch(dir)
22181 {
22182 case up:
22183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2531 times.
2531 if(cmb->usrflags&cflag10)
22184 return;
22185 2531 break;
22186 case down:
22187
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 9 times.
78 if(cmb->usrflags&cflag9)
22188 69 return;
22189 9 break;
22190 case left:
22191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(cmb->usrflags&cflag12)
22192 return;
22193 22 break;
22194 case right:
22195
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 17 times.
78 if(cmb->usrflags&cflag11)
22196 61 return;
22197 17 break;
22198 }
22199 2579 int32_t intbtn = cmb->attribytes[2];
22200
22201
2/2
✓ Branch 0 taken 2498 times.
✓ Branch 1 taken 81 times.
2579 if(intbtn) //
22202 {
22203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2498 times.
2498 if(cmb->usrflags & cflag13) //display prompt
22204 {
22205 2498 int altcmb = cmb->attributes[2]/10000;
22206 2498 prompt_combo = cmb->attributes[1]/10000;
22207
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2498 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2498 if(altcmb && ((islocked && !can_locked_combo(*cmb))
22208 || (isbosslocked && !(game->lvlitems[dlevel]&liBOSSKEY))))
22209 prompt_combo = altcmb;
22210 2498 prompt_cset = cmb->attribytes[4];
22211 2498 prompt_x = cmb->attrishorts[0];
22212 2498 prompt_y = cmb->attrishorts[1];
22213 2498 }
22214
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 2444 times.
2498 if(!getIntBtnInput(intbtn, true, true, false, false))
22215 {
22216 2444 return; //Button not pressed
22217 }
22218 54 }
22219
4/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 9 times.
81 else if(pushing < 8 || pushing % 8) return; //Not pushing against chest enough
22220
22221
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 21 times.
63 if(ischest)
22222 {
22223
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!trigger_chest(foundlayer, COMBOPOS(fx,fy))) return;
22224 42 }
22225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 else if(islockblock)
22226 {
22227
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 3 times.
21 if(!trigger_lockblock(foundlayer, COMBOPOS(fx,fy))) return;
22228 18 }
22229
3/4
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
60 if(intbtn && (cmb->usrflags & cflag13))
22230 51 prompt_combo = 0;
22231 4133956 }
22232
22233 14170183 void HeroClass::checkgenpush()
22234 {
22235 14170183 zfix bx, by;
22236 14170183 zfix bx2, by2;
22237
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3479897 times.
✓ Branch 2 taken 2818888 times.
✓ Branch 3 taken 3795145 times.
✓ Branch 4 taken 4076253 times.
14170183 switch(dir)
22238 {
22239 case up:
22240 3479897 by = y + (bigHitbox ? -2 : 6);
22241 3479897 by2 = by;
22242 3479897 bx = x + 4;
22243 3479897 bx2 = bx + 8;
22244 3479897 break;
22245 case down:
22246 2818888 by = y + 17;
22247 2818888 by2 = by;
22248 2818888 bx = x + 4;
22249 2818888 bx2 = bx + 8;
22250 2818888 break;
22251 case left:
22252 3795145 by = y + (bigHitbox ? 0 : 8);
22253 3795145 by2 = y + 8;
22254 3795145 bx = x - 2;
22255 3795145 bx2 = x - 2;
22256 3795145 break;
22257 case right:
22258 4076253 by = y + (bigHitbox ? 0 : 8);
22259 4076253 by2 = y + 8;
22260 4076253 bx = x + 17;
22261 4076253 bx2 = x + 17;
22262 4076253 break;
22263 }
22264 14170183 auto pos1 = COMBOPOS(bx,by);
22265 14170183 auto pos2 = COMBOPOS(bx2,by2);
22266
2/2
✓ Branch 0 taken 14170183 times.
✓ Branch 1 taken 99191281 times.
113361464 for(auto layer = 0; layer < 7; ++layer)
22267 {
22268 99191281 mapscr* tmp = FFCore.tempScreens[layer];
22269
22270 99191281 newcombo const& cmb1 = combobuf[tmp->data[pos1]];
22271
2/2
✓ Branch 0 taken 99190078 times.
✓ Branch 1 taken 1203 times.
99191281 if(cmb1.triggerflags[1] & combotriggerPUSH)
22272
5/6
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 14 times.
1204 if(pushing && !(pushing % zc_max(1,cmb1.trig_pushtime)))
22273 1 do_trigger_combo(layer,pos1);
22274
22275
2/2
✓ Branch 0 taken 81543875 times.
✓ Branch 1 taken 17647406 times.
99191281 if(pos1==pos2) continue;
22276
22277 17647406 newcombo const& cmb2 = combobuf[tmp->data[pos2]];
22278
2/2
✓ Branch 0 taken 17647131 times.
✓ Branch 1 taken 275 times.
17647406 if(cmb2.triggerflags[1] & combotriggerPUSH)
22279
4/6
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
275 if(pushing && !(pushing % zc_max(1,cmb2.trig_pushtime)))
22280 do_trigger_combo(layer,pos2);
22281 17647406 }
22282
2/2
✓ Branch 0 taken 13166019 times.
✓ Branch 1 taken 1004164 times.
14170183 if (!get_qr(qr_OLD_FFC_FUNCTIONALITY))
22283 {
22284 1004164 word c = tmpscr->numFFC();
22285
2/2
✓ Branch 0 taken 1004164 times.
✓ Branch 1 taken 3021619 times.
4025783 for(word i=0; i<c; i++)
22286 {
22287
4/4
✓ Branch 0 taken 2990128 times.
✓ Branch 1 taken 31491 times.
✓ Branch 2 taken 1323 times.
✓ Branch 3 taken 2988805 times.
3021619 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
22288 {
22289 32814 ffcdata& ffc = tmpscr->ffcs[i];
22290 32814 newcombo const& cmb3 = combobuf[ffc.data];
22291
1/2
✓ Branch 0 taken 32814 times.
✗ Branch 1 not taken.
32814 if(cmb3.triggerflags[1] & combotriggerPUSH)
22292 {
22293 if(pushing && !(pushing % zc_max(1,cmb3.trig_pushtime)))
22294 {
22295 do_trigger_combo_ffc(i);
22296 break;
22297 }
22298 }
22299 32814 }
22300 3021619 }
22301 1004164 }
22302 14170183 }
22303
22304 14170185 void HeroClass::checksigns() //Also checks for generic trigger buttons
22305 {
22306
5/6
✓ Branch 0 taken 14155491 times.
✓ Branch 1 taken 14694 times.
✓ Branch 2 taken 14136835 times.
✓ Branch 3 taken 18656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14136835 times.
14170185 if(toogam || z>0 || fakez>0) return;
22307
5/6
✓ Branch 0 taken 14017353 times.
✓ Branch 1 taken 119482 times.
✓ Branch 2 taken 236865 times.
✓ Branch 3 taken 13780488 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 236865 times.
14136835 if(msg_active || (msg_onscreen && get_qr(qr_MSGDISAPPEAR)))
22308 119482 return; //Don't overwrite a message waiting to be dismissed
22309 14017353 zfix bx, by;
22310 14017353 zfix bx2, by2;
22311 14017353 zfix fx(-1), fy(-1);
22312
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3379991 times.
✓ Branch 2 taken 2806347 times.
✓ Branch 3 taken 3779475 times.
✓ Branch 4 taken 4051540 times.
14017353 switch(dir)
22313 {
22314 case up:
22315 3379991 by = y + (bigHitbox ? -2 : 6);
22316 3379991 by2 = by;
22317 3379991 bx = x + 4;
22318 3379991 bx2 = bx + 8;
22319 3379991 break;
22320 case down:
22321 2806347 by = y + 17;
22322 2806347 by2 = by;
22323 2806347 bx = x + 4;
22324 2806347 bx2 = bx + 8;
22325 2806347 break;
22326 case left:
22327 3779475 by = y + (bigHitbox ? 0 : 8);
22328 3779475 by2 = y + 8;
22329 3779475 bx = x - 2;
22330 3779475 bx2 = x - 2;
22331 3779475 break;
22332 case right:
22333 4051540 by = y + (bigHitbox ? 0 : 8);
22334 4051540 by2 = y + 8;
22335 4051540 bx = x + 17;
22336 4051540 bx2 = x + 17;
22337 4051540 break;
22338 }
22339
22340 14017353 int32_t found = -1;
22341 14017353 int32_t foundffc = -1;
22342 14017353 int32_t found_lyr = 0;
22343 14017353 bool found_sign = false;
22344 14017353 int32_t tmp_cid = MAPCOMBO(bx,by);
22345 14017353 newcombo const* tmp_cmb = &combobuf[tmp_cid];
22346
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14017353 times.
✓ Branch 2 taken 14011160 times.
✓ Branch 3 taken 6193 times.
28034706 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
22347 14017353 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, -1))
22348 {
22349 6193 found = tmp_cid;
22350 6193 fx = bx; fy = by;
22351
2/2
✓ Branch 0 taken 12386 times.
✓ Branch 1 taken 6193 times.
18579 for (int32_t i = 0; i <= 1; ++i)
22352 {
22353
2/2
✓ Branch 0 taken 9401 times.
✓ Branch 1 taken 2985 times.
12386 if(tmpscr2[i].valid!=0)
22354 {
22355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2985 times.
2985 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22356 {
22357 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
22358 }
22359 else
22360 {
22361
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2985 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2985 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
22362 }
22363 2985 }
22364 12386 }
22365 6193 }
22366 14017353 tmp_cid = MAPCOMBO(bx2,by2);
22367 14017353 tmp_cmb = &combobuf[tmp_cid];
22368
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14017353 times.
✓ Branch 2 taken 14011032 times.
✓ Branch 3 taken 6321 times.
28034706 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
22369 14017353 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, -1))
22370 {
22371 6321 found = tmp_cid;
22372 6321 fx = bx2; fy = by2;
22373
2/2
✓ Branch 0 taken 12642 times.
✓ Branch 1 taken 6321 times.
18963 for (int32_t i = 0; i <= 1; ++i)
22374 {
22375
2/2
✓ Branch 0 taken 9745 times.
✓ Branch 1 taken 2897 times.
12642 if(tmpscr2[i].valid!=0)
22376 {
22377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2897 times.
2897 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22378 {
22379 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
22380 }
22381 else
22382 {
22383
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2897 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2897 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
22384 }
22385 2897 }
22386 12642 }
22387 6321 }
22388
22389
2/2
✓ Branch 0 taken 13019554 times.
✓ Branch 1 taken 997799 times.
14017353 if (!get_qr(qr_OLD_FFC_FUNCTIONALITY))
22390 {
22391 997799 word c = tmpscr->numFFC();
22392
2/2
✓ Branch 0 taken 997799 times.
✓ Branch 1 taken 2999851 times.
3997650 for(word i=0; i<c; i++)
22393 {
22394
4/4
✓ Branch 0 taken 2968554 times.
✓ Branch 1 taken 31297 times.
✓ Branch 2 taken 1323 times.
✓ Branch 3 taken 2967231 times.
2999851 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
22395 {
22396 32620 ffcdata& ffc = tmpscr->ffcs[i];
22397 32620 tmp_cmb = &combobuf[ffc.data];
22398
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 32620 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32620 times.
32620 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
22399 32620 || tmp_cmb->triggerbtn) && true) //!TODO: FFC effect flag?
22400 {
22401 foundffc = i;
22402 break;
22403 }
22404 32620 }
22405 2999851 }
22406 997799 }
22407
22408
3/4
✓ Branch 0 taken 14010851 times.
✓ Branch 1 taken 6502 times.
✓ Branch 2 taken 14010851 times.
✗ Branch 3 not taken.
14017353 if(found<0 && foundffc < 0)
22409 {
22410
2/2
✓ Branch 0 taken 14008860 times.
✓ Branch 1 taken 84055850 times.
98064710 for(int32_t i=0; i<6; i++)
22411 {
22412 84055850 tmp_cid = MAPCOMBO2(i,bx,by);
22413 84055850 tmp_cmb = &combobuf[tmp_cid];
22414
4/4
✓ Branch 0 taken 694 times.
✓ Branch 1 taken 84055156 times.
✓ Branch 2 taken 84053912 times.
✓ Branch 3 taken 1938 times.
168111700 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
22415 84055850 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, i))
22416 {
22417 1938 found = tmp_cid;
22418 1938 found_lyr = i+1;
22419 1938 fx = bx; fy = by;
22420
4/4
✓ Branch 0 taken 1277 times.
✓ Branch 1 taken 661 times.
✓ Branch 2 taken 360 times.
✓ Branch 3 taken 917 times.
1938 if (i == 0 && tmpscr2[1].valid!=0)
22421 {
22422
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 37 times.
917 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22423 {
22424
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
880 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
22425 880 }
22426 else
22427 {
22428
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
22429 }
22430 917 }
22431 1938 }
22432 84055850 tmp_cid = MAPCOMBO2(i,bx2,by2);
22433 84055850 tmp_cmb = &combobuf[tmp_cid];
22434
4/4
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 84055164 times.
✓ Branch 2 taken 84054019 times.
✓ Branch 3 taken 1831 times.
168111700 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
22435 84055850 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, i))
22436 {
22437 1831 found = tmp_cid;
22438 1831 found_lyr = i+1;
22439 1831 fx = bx2; fy = by2;
22440
4/4
✓ Branch 0 taken 1178 times.
✓ Branch 1 taken 653 times.
✓ Branch 2 taken 363 times.
✓ Branch 3 taken 815 times.
1831 if (i == 0 && tmpscr2[1].valid!=0)
22441 {
22442
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 35 times.
815 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22443 {
22444
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
780 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
22445 780 }
22446 else
22447 {
22448
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
22449 }
22450 815 }
22451 1831 }
22452
2/2
✓ Branch 0 taken 84053859 times.
✓ Branch 1 taken 1991 times.
84055850 if(found>-1) break;
22453 84053859 }
22454 14010851 }
22455
22456
3/4
✓ Branch 0 taken 14008860 times.
✓ Branch 1 taken 8493 times.
✓ Branch 2 taken 14008860 times.
✗ Branch 3 not taken.
14017353 if(found<0&&foundffc<0) return;
22457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8493 times.
8493 newcombo const& cmb = (foundffc<0?combobuf[found]:combobuf[tmpscr->ffcs[foundffc].data]);
22458
22459 8493 byte signInput = 0;
22460 8493 bool didsign = false, didprompt = false;
22461
3/4
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 7761 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 732 times.
8512 if(cmb.type == cSIGNPOST && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
22462 {
22463
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 577 times.
✓ Branch 2 taken 116 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 35 times.
732 switch(dir)
22464 {
22465 case up:
22466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 577 times.
577 if(cmb.usrflags&cflag10)
22467 goto endsigns;
22468 577 break;
22469 case down:
22470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(cmb.usrflags&cflag9)
22471 goto endsigns;
22472 116 break;
22473 case left:
22474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(cmb.usrflags&cflag12)
22475 goto endsigns;
22476 4 break;
22477 case right:
22478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(cmb.usrflags&cflag11)
22479 goto endsigns;
22480 35 break;
22481 }
22482 732 int32_t intbtn = cmb.attribytes[2];
22483
22484
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(intbtn) //
22485 {
22486 732 signInput = getIntBtnInput(intbtn, true, true, false, false);
22487
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 713 times.
732 if(!signInput)
22488 {
22489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 713 times.
713 if(cmb.usrflags & cflag13) //display prompt
22490 {
22491 713 prompt_combo = cmb.attributes[1]/10000;
22492 713 prompt_cset = cmb.attribytes[4];
22493 713 prompt_x = cmb.attrishorts[0];
22494 713 prompt_y = cmb.attrishorts[1];
22495 713 didprompt = true;
22496 713 }
22497 713 goto endsigns; //Button not pressed
22498 }
22499 19 }
22500 else if(pushing < 8 || pushing%8) goto endsigns; //Not pushing against sign enough
22501
22502 19 trigger_sign(cmb);
22503 19 didsign = true;
22504 19 }
22505 endsigns:
22506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8493 times.
8493 if(cpos_get(found_lyr, COMBOPOS(fx,fy)).trig_cd) return;
22507
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 521 times.
✓ Branch 2 taken 6986 times.
✓ Branch 3 taken 488 times.
✓ Branch 4 taken 498 times.
8493 switch(dir)
22508 {
22509 case down:
22510
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 116 times.
521 if(!(cmb.triggerflags[0] & combotriggerBTN_TOP))
22511 116 return;
22512 405 break;
22513 case up:
22514
2/2
✓ Branch 0 taken 6409 times.
✓ Branch 1 taken 577 times.
6986 if(!(cmb.triggerflags[0] & combotriggerBTN_BOTTOM))
22515 577 return;
22516 6409 break;
22517 case right:
22518
2/2
✓ Branch 0 taken 453 times.
✓ Branch 1 taken 35 times.
488 if(!(cmb.triggerflags[0] & combotriggerBTN_LEFT))
22519 35 return;
22520 453 break;
22521 case left:
22522
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 79 times.
498 if(!(cmb.triggerflags[0] & combotriggerBTN_RIGHT))
22523 79 return;
22524 419 break;
22525 }
22526
4/6
✓ Branch 0 taken 7686 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7515 times.
✓ Branch 3 taken 171 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7515 times.
7686 if(cmb.triggerbtn && (getIntBtnInput(cmb.triggerbtn, true, true, false, false) || checkIntBtnVal(cmb.triggerbtn, signInput)))
22527 {
22528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 171 times.
171 if (foundffc >= 0)
22529 do_trigger_combo_ffc(foundffc, didsign ? ctrigIGNORE_SIGN : 0);
22530 else
22531 171 do_trigger_combo(found_lyr, COMBOPOS(fx,fy), didsign ? ctrigIGNORE_SIGN : 0);
22532 171 }
22533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7515 times.
7515 else if(didprompt)
22534 return;
22535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7515 times.
7515 else if(cmb.type == cBUTTONPROMPT)
22536 {
22537 prompt_combo = cmb.attributes[0]/10000;
22538 prompt_cset = cmb.attribytes[0];
22539 prompt_x = cmb.attrishorts[0];
22540 prompt_y = cmb.attrishorts[1];
22541 }
22542
2/2
✓ Branch 0 taken 6000 times.
✓ Branch 1 taken 1515 times.
7515 else if(cmb.prompt_cid)
22543 {
22544 6000 prompt_combo = cmb.prompt_cid;
22545 6000 prompt_cset = cmb.prompt_cs;
22546 6000 prompt_x = cmb.prompt_x;
22547 6000 prompt_y = cmb.prompt_y;
22548 6000 }
22549 14170185 }
22550
22551 14146038 void HeroClass::checklocked()
22552 {
22553
2/2
✓ Branch 0 taken 14694 times.
✓ Branch 1 taken 14131344 times.
14146038 if(toogam) return; //Walk through walls.
22554
2/2
✓ Branch 0 taken 6255570 times.
✓ Branch 1 taken 7875774 times.
14131344 if(!isdungeon()) return;
22555
4/4
✓ Branch 0 taken 6203318 times.
✓ Branch 1 taken 52252 times.
✓ Branch 2 taken 12798 times.
✓ Branch 3 taken 6190520 times.
6255570 if( !diagonalMovement && pushing!=8) return;
22556 //This is required to allow the player to open a door, while sliding along a wall (pressing in the direction of the door, and sliding left or right)
22557
4/4
✓ Branch 0 taken 52252 times.
✓ Branch 1 taken 12798 times.
✓ Branch 2 taken 2677 times.
✓ Branch 3 taken 49575 times.
65050 if ( diagonalMovement && pushing < 8 ) return; //Allow wall walking Should I add a quest rule for this? -Z
22558
22559 15475 optional<int> openDir;
22560
3/4
✓ Branch 0 taken 12798 times.
✓ Branch 1 taken 2677 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12798 times.
15475 if ( diagonalMovement || get_qr(qr_DISABLE_4WAY_GRIDLOCK))
22561 {
22562
8/8
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 2534 times.
✓ Branch 2 taken 97 times.
✓ Branch 3 taken 46 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 41 times.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 32 times.
2677 if(y <= 32 && x >= 112 && x <= 128 && Y_DIR(dir) == up)
22563 32 openDir = up;
22564
8/8
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 2325 times.
✓ Branch 2 taken 196 times.
✓ Branch 3 taken 124 times.
✓ Branch 4 taken 87 times.
✓ Branch 5 taken 109 times.
✓ Branch 6 taken 56 times.
✓ Branch 7 taken 31 times.
2645 else if(y >= 128 && x >= 112 && x <= 128 && Y_DIR(dir) == down)
22565 31 openDir = down;
22566
5/8
✓ Branch 0 taken 1468 times.
✓ Branch 1 taken 1146 times.
✓ Branch 2 taken 279 times.
✓ Branch 3 taken 1189 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 279 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2614 else if(y > 72 && y < 88 && x <= 32 && X_DIR(dir) == left)
22567 openDir = left;
22568
5/8
✓ Branch 0 taken 1468 times.
✓ Branch 1 taken 1146 times.
✓ Branch 2 taken 279 times.
✓ Branch 3 taken 1189 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 279 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2614 else if(y > 72 && y < 88 && x >= 208 && X_DIR(dir) == right)
22569 openDir = right;
22570 2677 }
22571 else
22572 {
22573
6/6
✓ Branch 0 taken 1751 times.
✓ Branch 1 taken 11047 times.
✓ Branch 2 taken 474 times.
✓ Branch 3 taken 1277 times.
✓ Branch 4 taken 61 times.
✓ Branch 5 taken 413 times.
12798 if(y <= 32 && x == 120 && Y_DIR(dir) == up)
22574 413 openDir = up;
22575
6/6
✓ Branch 0 taken 1806 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 252 times.
✓ Branch 3 taken 1554 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 227 times.
12385 else if(y >= 128 && x == 120 && Y_DIR(dir) == down)
22576 227 openDir = down;
22577
6/6
✓ Branch 0 taken 1831 times.
✓ Branch 1 taken 10327 times.
✓ Branch 2 taken 339 times.
✓ Branch 3 taken 1492 times.
✓ Branch 4 taken 114 times.
✓ Branch 5 taken 225 times.
12158 else if(y == 80 && x <= 32 && X_DIR(dir) == left)
22578 225 openDir = left;
22579
6/6
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 10327 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 1183 times.
✓ Branch 4 taken 67 times.
✓ Branch 5 taken 356 times.
11933 else if(y == 80 && x >= 208 && X_DIR(dir) == right)
22580 356 openDir = right;
22581 }
22582
2/2
✓ Branch 0 taken 14191 times.
✓ Branch 1 taken 1284 times.
15475 if(openDir)
22583 {
22584 1284 int d = *openDir;
22585
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 920 times.
1284 if(tmpscr->door[d]==dLOCKED)
22586 {
22587
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 14 times.
364 if(usekey())
22588 {
22589 350 putdoor(scrollbuf,0,d,dUNLOCKED);
22590 350 tmpscr->door[d]=dUNLOCKED;
22591 350 set_doorstate(d);
22592 350 sfx(WAV_DOOR);
22593 350 markBmap(-1);
22594 350 }
22595 14 else return;
22596 350 }
22597
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 56 times.
920 else if(tmpscr->door[d]==dBOSS)
22598 {
22599
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 5 times.
56 if(game->lvlitems[dlevel]&liBOSSKEY)
22600 {
22601 51 putdoor(scrollbuf,0,d,dOPENBOSS);
22602 51 tmpscr->door[d]=dOPENBOSS;
22603 51 set_doorstate(d);
22604 51 sfx(WAV_DOOR);
22605 51 markBmap(-1);
22606 // Run Boss Key Script
22607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3468 times.
3468 for ( int32_t q = 0; q < MAXITEMS; ++q )
22608
2/2
✓ Branch 0 taken 3417 times.
✓ Branch 1 taken 51 times.
3468 if ( itemsbuf[q].family == itype_bosskey )
22609 {
22610
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
51 if (itemsbuf[q].script && !(FFCore.doscript(ScriptType::Item, q) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
22611 {
22612 FFCore.reset_script_engine_data(ScriptType::Item, q);
22613 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q);
22614 FFCore.deallocateAllScriptOwned(ScriptType::Item, q);
22615 }
22616 51 break;
22617 }
22618 51 }
22619 5 else return;
22620 51 }
22621 1265 }
22622 14146038 }
22623
22624 14146038 void HeroClass::checkswordtap()
22625 {
22626
6/6
✓ Branch 0 taken 6863422 times.
✓ Branch 1 taken 7282616 times.
✓ Branch 2 taken 40969 times.
✓ Branch 3 taken 6822453 times.
✓ Branch 4 taken 40006 times.
✓ Branch 5 taken 963 times.
14146038 if(attack!=wSword || charging<=0 || pushing<8) return;
22627
22628 963 int32_t bx=x;
22629 963 int32_t by=y+8;
22630
22631
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 307 times.
✓ Branch 4 taken 262 times.
963 switch(dir)
22632 {
22633 case up:
22634
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 65 times.
282 if(!Up()) return;
22635
22636 217 by-=16;
22637 217 break;
22638
22639 case down:
22640
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 20 times.
112 if(!Down()) return;
22641
22642 92 by+=16;
22643 92 bx+=8;
22644 92 break;
22645
22646 case left:
22647
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 139 times.
307 if(!Left()) return;
22648
22649 168 bx-=16;
22650 168 by+=8;
22651 168 break;
22652
22653 case right:
22654
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 72 times.
262 if(!Right()) return;
22655
22656 190 bx+=16;
22657 190 by+=8;
22658 190 break;
22659 }
22660
22661
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 667 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 667 times.
✓ Branch 4 taken 513 times.
✓ Branch 5 taken 154 times.
667 if(!_walkflag(bx,by,0,SWITCHBLOCK_STATE)) return;
22662
22663 513 attackclk=SWORDTAPFRAME;
22664 513 pushing=-8; //16 frames between taps
22665 513 tapping=true;
22666
22667 513 int32_t type = COMBOTYPE(bx,by);
22668
22669
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 500 times.
513 if(!isCuttableType(type))
22670 {
22671 500 int tap_sfx = -1;
22672 500 auto pos = COMBOPOS(bx,by);
22673 500 bool hollow = false;
22674
2/2
✓ Branch 0 taken 500 times.
✓ Branch 1 taken 4000 times.
4500 for(int lyr = 7; lyr >= 0; --lyr)
22675 {
22676 4000 mapscr* m = FFCore.tempScreens[lyr];
22677 4000 newcombo const& cmb = combobuf[m->data[pos]];
22678
1/2
✓ Branch 0 taken 4000 times.
✗ Branch 1 not taken.
4000 if(cmb.sfx_tap)
22679 {
22680 tap_sfx = cmb.sfx_tap;
22681 break;
22682 }
22683
3/4
✓ Branch 0 taken 3991 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3991 times.
7991 if(m->sflag[pos] == mfBOMB || m->sflag[pos] == mfSBOMB
22684
2/4
✓ Branch 0 taken 3991 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3991 times.
✗ Branch 3 not taken.
3991 || cmb.flag == mfBOMB || cmb.flag == mfSBOMB)
22685 9 hollow = true;
22686 4000 }
22687
2/4
✓ Branch 0 taken 500 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500 times.
500 if(tap_sfx < 0 && get_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX))
22688 {
22689
3/10
✓ Branch 0 taken 491 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 491 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
500 if(hollow || (tmpscr->door[dir]==dBOMB && ((dir==up||dir==down)
22690 ? (bx>=112 && bx<144 && (by>=144 || by<=32))
22691 : by>=72 && by<104 && (bx>=224 || bx<=32))))
22692 9 tap_sfx = QMisc.miscsfx[sfxTAP_HOLLOW];
22693 500 }
22694
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 491 times.
500 if(tap_sfx < 0)
22695 491 tap_sfx = QMisc.miscsfx[sfxTAP];
22696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 500 times.
500 if(tap_sfx)
22697 500 sfx(tap_sfx,pan(x.getInt()));
22698 500 }
22699 14146038 }
22700
22701 27606 void HeroClass::fairycircle(int32_t type)
22702 {
22703
2/2
✓ Branch 0 taken 23253 times.
✓ Branch 1 taken 4353 times.
27606 if(fairyclk==0)
22704 {
22705
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4333 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 19 times.
4353 switch(type)
22706 {
22707 case REFILL_LIFE:
22708
2/2
✓ Branch 0 taken 4177 times.
✓ Branch 1 taken 156 times.
4333 if(didstuff&did_fairy) return;
22709
22710 156 didstuff|=did_fairy;
22711 156 break;
22712
22713 case REFILL_MAGIC:
22714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(didstuff&did_magic) return;
22715
22716 1 didstuff|=did_magic;
22717 1 break;
22718
22719 case REFILL_ALL:
22720
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 2 times.
19 if(didstuff&did_all) return;
22721
22722 2 didstuff|=did_all;
22723 2 }
22724
22725 159 refill_what=type;
22726 159 refill_why=REFILL_FAIRY;
22727 159 StartRefill(type);
22728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
22729 159 else {action=freeze; FFCore.setHeroAction(freeze);}
22730 159 holdclk=0;
22731 159 hopclk=0;
22732 159 }
22733
22734 23412 ++fairyclk;
22735
22736
2/2
✓ Branch 0 taken 10557 times.
✓ Branch 1 taken 12855 times.
23412 if(refilling!=REFILL_FAIRYDONE)
22737 {
22738
2/2
✓ Branch 0 taken 10398 times.
✓ Branch 1 taken 159 times.
10557 if(!refill())
22739 159 refilling=REFILL_FAIRYDONE;
22740 10557 }
22741
22742
2/2
✓ Branch 0 taken 12697 times.
✓ Branch 1 taken 158 times.
12855 else if(++holdclk>80)
22743 {
22744 158 reset_swordcharge();
22745 158 attackclk=0;
22746 158 action=none; FFCore.setHeroAction(none);
22747 158 fairyclk=0;
22748 158 holdclk=0;
22749 158 refill_why = 0;
22750 158 refilling=REFILL_NONE;
22751 158 map_bkgsfx(true);
22752 158 }
22753 27606 }
22754
22755 1391989 int32_t touchcombo(int32_t x,int32_t y)
22756 {
22757
2/2
✓ Branch 0 taken 2783910 times.
✓ Branch 1 taken 1391921 times.
4175831 for (int32_t i = 0; i <= 1; ++i)
22758 {
22759
2/2
✓ Branch 0 taken 1952432 times.
✓ Branch 1 taken 831478 times.
2783910 if(tmpscr2[i].valid!=0)
22760 {
22761
2/2
✓ Branch 0 taken 667069 times.
✓ Branch 1 taken 164409 times.
831478 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22762 {
22763
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 667069 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
667069 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && !_walkflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
22764 667069 }
22765 else
22766 {
22767
4/4
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 164308 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 68 times.
164409 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && _effectflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
22768 }
22769 831410 }
22770 2783842 }
22771
2/2
✓ Branch 0 taken 1390303 times.
✓ Branch 1 taken 1618 times.
1391921 if (!_effectflag(x,y,1, -1)) return 0;
22772 1390303 newcombo const& cmb = combobuf[MAPCOMBO(x,y)];
22773
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 1390255 times.
1390303 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
22774 48 return 0;
22775
3/3
✓ Branch 0 taken 3242 times.
✓ Branch 1 taken 1385086 times.
✓ Branch 2 taken 1927 times.
1390255 switch(cmb.type)
22776 {
22777 case cBSGRAVE:
22778 case cGRAVE:
22779
3/4
✓ Branch 0 taken 2255 times.
✓ Branch 1 taken 987 times.
✓ Branch 2 taken 2255 times.
✗ Branch 3 not taken.
3242 if(MAPFLAG(x,y)||MAPCOMBOFLAG(x,y)) //!DIMITODO: all flags break graves, not just push flags
22780 {
22781 987 break;
22782 }
22783
22784 [[fallthrough]];
22785 case cARMOS:
22786 {
22787 4182 return cmb.type;
22788 }
22789 }
22790
22791 1386073 return 0;
22792 1391989 }
22793
22794 //static int32_t COMBOX(int32_t pos) { return ((pos)%16*16); }
22795 //static int32_t COMBOY(int32_t pos) { return ((pos)&0xF0); }
22796
22797 static int32_t GridX(int32_t x)
22798 {
22799 return (x >> 4) << 4;
22800 }
22801
22802 //Snaps 'y' to the combo grid
22803 //Equivalent to calling ComboY(ComboAt(foo,y));
22804 static int32_t GridY(int32_t y)
22805 {
22806 return (y >> 4) << 4;
22807 }
22808
22809 9 int32_t grabComboFromPos(int32_t pos, int32_t type)
22810 {
22811
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 for(int32_t lyr = 6; lyr > -1; --lyr)
22812 {
22813 63 int32_t id = FFCore.tempScreens[lyr]->data[pos];
22814
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 54 times.
63 if(combobuf[id].type == type)
22815 9 return id;
22816 54 }
22817 return -1;
22818 9 }
22819
22820 typedef word spot_t;
22821 static int32_t typeMap[176];
22822 static int32_t customTypeMap[176];
22823 static int32_t istrig[176];
22824 static int32_t heropos = -1;
22825 static const int32_t SPTYPE_SOLID = -1;
22826 enum
22827 {
22828 beamoffs_gr, beamoffs_up, beamoffs_down, beamoffs_left, beamoffs_right,
22829 beamoffs_uleft, beamoffs_uright, beamoffs_dleft, beamoffs_dright, beamoffs_vert,
22830 beamoffs_horz, beamoffs_notup, beamoffs_notdown, beamoffs_notleft, beamoffs_notright,
22831 beamoffs_all, beamoffs_max
22832 };
22833 struct lightbeam_xy
22834 {
22835 int16_t x;
22836 int16_t y;
22837 lightbeam_xy(int32_t nx, int32_t ny)
22838 {
22839 x = vbound(nx,-32768,32767);
22840 y = vbound(ny,-32768,32767);
22841 }
22842 lightbeam_xy(dword ffpos)
22843 {
22844 x = int16_t(ffpos >> 16);
22845 y = int16_t(ffpos & 0xFFFF);
22846 }
22847 bool valid() const
22848 {
22849 return valid(x,y);
22850 }
22851 void bound()
22852 {
22853 x = vbound(x,0-16,255+16);
22854 y = vbound(y,0-16,175+16);
22855 }
22856 dword ffpos() const
22857 {
22858 return (word(x)<<16)|word(y&0xFFFF);
22859 }
22860 size_t pos() const
22861 {
22862 return COMBOPOS(vbound(x,0,255),vbound(y,0,175));
22863 }
22864 bool herocollide(byte beamwid)
22865 {
22866 int bx = x-beamwid/2, by = y-beamwid/2;
22867 int hx = Hero.x.getInt(), hy = Hero.y.getInt();
22868 return hx+15 >= bx && hx < bx+beamwid
22869 && hy+15 >= by && hy < by+beamwid;
22870 }
22871 static bool valid(int32_t x, int32_t y)
22872 {
22873 return x+16 >= 0 && x-16 < 256 && y+16 >= 0 && y-16 < 176;
22874 }
22875 };
22876 #define SP_VISITED 0x1
22877 #define SP_FLAGS 0x01E
22878 #define SP_GOFLAGS 0x1E0
22879 #define SP_MASK (SP_VISITED|SP_FLAGS)
22880 #define SP_FLAG(dir) (0x2<<dir)
22881 #define SP_GOFLAG(dir) (0x20<<dir)
22882 #define BEAM_AGE_LIMIT 512
22883 14283 static void handleBeam(spot_t* grid, size_t age, byte spotdir, int32_t curpos, byte set, bool block, bool refl)
22884 {
22885
2/2
✓ Branch 0 taken 7620 times.
✓ Branch 1 taken 6663 times.
14283 if(spotdir > 3) return; //invalid dir
22886
2/2
✓ Branch 0 taken 5429 times.
✓ Branch 1 taken 1234 times.
6663 int32_t trigflag = set ? (1 << (set-1)) : ~0;
22887 6663 bool doAge = true;
22888 6663 spot_t f = 0;
22889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70632 times.
70632 while(unsigned(curpos) < 176)
22890 {
22891 70632 bool block_light = false;
22892 70632 f = SP_GOFLAG(spotdir);
22893
2/2
✓ Branch 0 taken 70177 times.
✓ Branch 1 taken 455 times.
70632 if((grid[curpos] & f) == f)
22894 455 return;
22895 70177 else grid[curpos] |= f;
22896 70177 f = SP_FLAG(spotdir);
22897
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 70024 times.
70177 if((grid[curpos] & f) != f)
22898 {
22899 70024 grid[curpos] |= f;
22900 70024 istrig[curpos] |= trigflag;
22901 70024 doAge = false;
22902 70024 age = 0;
22903 70024 }
22904
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 16931 times.
✓ Branch 2 taken 9603 times.
✓ Branch 3 taken 23595 times.
✓ Branch 4 taken 20048 times.
70177 switch(spotdir)
22905 {
22906 case up:
22907 16931 curpos -= 0x10;
22908 16931 break;
22909 case down:
22910 9603 curpos += 0x10;
22911 9603 break;
22912 case left:
22913
1/2
✓ Branch 0 taken 23595 times.
✗ Branch 1 not taken.
23595 if(!(curpos%0x10))
22914 curpos = -1;
22915 23595 else --curpos;
22916 23595 break;
22917 case right:
22918 20048 ++curpos;
22919
1/2
✓ Branch 0 taken 20048 times.
✗ Branch 1 not taken.
20048 if(!(curpos%0x10))
22920 curpos = -1;
22921 20048 break;
22922 }
22923
1/2
✓ Branch 0 taken 70177 times.
✗ Branch 1 not taken.
70177 if(unsigned(curpos) >= 176) return;
22924
2/2
✓ Branch 0 taken 6208 times.
✓ Branch 1 taken 63969 times.
70177 switch(typeMap[curpos])
22925 {
22926 case SPTYPE_SOLID: case cBLOCKALL:
22927 6208 curpos = -1;
22928 6208 break;
22929 }
22930
3/6
✓ Branch 0 taken 1061 times.
✓ Branch 1 taken 69116 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1061 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
70177 if((curpos==heropos) && block && (spotdir == oppositeDir[Hero.getDir()]))
22931 curpos = -1;
22932
2/2
✓ Branch 0 taken 63969 times.
✓ Branch 1 taken 6208 times.
70177 if(unsigned(curpos) >= 176) return;
22933
22934 63969 f = SP_FLAG(oppositeDir[spotdir]);
22935
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 63816 times.
63969 if((grid[curpos] & f) != f)
22936 {
22937 63816 grid[curpos] |= f;
22938 63816 istrig[curpos] |= trigflag;
22939 63816 doAge = false;
22940 63816 age = 0;
22941 63816 }
22942
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 63816 times.
63969 if(doAge)
22943 {
22944
1/2
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
153 if(++age > BEAM_AGE_LIMIT)
22945 return;
22946 153 }
22947 63816 else doAge = true;
22948
22949
4/4
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 63094 times.
✓ Branch 2 taken 147 times.
✓ Branch 3 taken 728 times.
63969 if(curpos==heropos && refl)
22950 728 spotdir = Hero.getDir();
22951
4/8
✓ Branch 0 taken 46363 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9088 times.
✓ Branch 4 taken 7781 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
63241 else switch(typeMap[curpos])
22952 {
22953 case cLIGHTTARGET:
22954 {
22955 9 auto cid = grabComboFromPos(curpos, cLIGHTTARGET);
22956
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 if(cid > -1 && combobuf[cid].usrflags&cflag3) //Blocks light
22957 return;
22958
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6 times.
9 if(get_qr(qr_BROKEN_LIGHTBEAM_HITBOX))
22959 6 spotdir = oppositeDir[spotdir];
22960 9 break;
22961 }
22962 case cMIRROR:
22963 spotdir = oppositeDir[spotdir];
22964 break;
22965 case cMIRRORSLASH:
22966
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2991 times.
✓ Branch 2 taken 3402 times.
✓ Branch 3 taken 1726 times.
✓ Branch 4 taken 969 times.
9088 switch(spotdir)
22967 {
22968 case up:
22969 2991 spotdir = right; break;
22970 case right:
22971 3402 spotdir = up; break;
22972 case down:
22973 1726 spotdir = left; break;
22974 case left:
22975 969 spotdir = down; break;
22976 }
22977 9088 break;
22978 case cMIRRORBACKSLASH:
22979
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1927 times.
✓ Branch 2 taken 1814 times.
✓ Branch 3 taken 1522 times.
✓ Branch 4 taken 2518 times.
7781 switch(spotdir)
22980 {
22981 case up:
22982 1927 spotdir = left; break;
22983 case left:
22984 1814 spotdir = up; break;
22985 case down:
22986 1522 spotdir = right; break;
22987 case right:
22988 2518 spotdir = down; break;
22989 }
22990 7781 break;
22991 case cMAGICPRISM:
22992 for(byte d = 0; d < 4; ++d)
22993 {
22994 if(d == oppositeDir[spotdir]) continue;
22995 handleBeam(grid, age, d, curpos, set, block, refl);
22996 }
22997 return;
22998 case cMAGICPRISM4:
22999 for(byte d = 0; d < 4; ++d)
23000 {
23001 handleBeam(grid, age, d, curpos, set, block, refl);
23002 }
23003 return;
23004 case cMIRRORNEW:
23005 {
23006 auto cid = customTypeMap[curpos];
23007 if(unsigned(cid) >= MAXCOMBOS) break;
23008 newcombo const& cmb = combobuf[cid];
23009 byte newdir = cmb.attribytes[spotdir];
23010 if(newdir > 7) return;
23011 if(newdir > 3) break;
23012 spotdir = newdir;
23013 break;
23014 }
23015 }
23016 }
23017 14283 }
23018 static void handleFFBeam(std::map<dword,spot_t>& grid, size_t age, byte spotdir, lightbeam_xy curxy, byte set, bool block, bool refl, byte beamwid)
23019 {
23020 if(spotdir > 3) return; //invalid dir
23021 int32_t trigflag = set ? (1 << (set-1)) : ~0;
23022 bool doAge = true;
23023 byte f = 0;
23024 while(curxy.valid())
23025 {
23026 bool block_light = false;
23027 f = SP_FLAG(spotdir);
23028 if((grid[curxy.ffpos()] & f) != f)
23029 {
23030 grid[curxy.ffpos()] |= f;
23031 istrig[curxy.pos()] |= trigflag;
23032 doAge = false;
23033 age = 0;
23034 }
23035 switch(spotdir)
23036 {
23037 case up:
23038 curxy.y -= 16;
23039 break;
23040 case down:
23041 curxy.y += 16;
23042 break;
23043 case left:
23044 curxy.x -= 16;
23045 break;
23046 case right:
23047 curxy.x += 16;
23048 break;
23049 }
23050 auto curpos = curxy.pos();
23051 switch(typeMap[curpos])
23052 {
23053 case SPTYPE_SOLID: case cBLOCKALL:
23054 return;
23055 case cMIRRORNEW:
23056 {
23057 auto cid = customTypeMap[curpos];
23058 if(unsigned(cid) >= MAXCOMBOS) break;
23059 newcombo const& cmb = combobuf[cid];
23060 byte newdir = cmb.attribytes[spotdir];
23061 if(newdir > 7) return;
23062 break;
23063 }
23064 }
23065 bool collided_hero = heropos > -1 && curxy.herocollide(beamwid);
23066 if(block && (spotdir == oppositeDir[Hero.getDir()]) && collided_hero)
23067 return;
23068
23069 f = SP_FLAG(oppositeDir[spotdir]);
23070 if((grid[curxy.ffpos()] & f) != f)
23071 {
23072 grid[curxy.ffpos()] |= f;
23073 istrig[curpos] |= trigflag;
23074 doAge = false;
23075 age = 0;
23076 }
23077 if(!curxy.valid()) return;
23078 if(doAge)
23079 {
23080 if(++age > BEAM_AGE_LIMIT)
23081 return;
23082 }
23083 else doAge = true;
23084
23085 if(refl && collided_hero)
23086 spotdir = Hero.getDir();
23087 else switch(typeMap[curpos])
23088 {
23089 case cLIGHTTARGET:
23090 {
23091 auto cid = grabComboFromPos(curpos, cLIGHTTARGET);
23092 if(cid > -1 && combobuf[cid].usrflags&cflag3) //Blocks light
23093 return;
23094 if(get_qr(qr_BROKEN_LIGHTBEAM_HITBOX))
23095 spotdir = oppositeDir[spotdir];
23096 break;
23097 }
23098 case cMIRROR:
23099 spotdir = oppositeDir[spotdir];
23100 break;
23101 case cMIRRORSLASH:
23102 switch(spotdir)
23103 {
23104 case up:
23105 spotdir = right; break;
23106 case right:
23107 spotdir = up; break;
23108 case down:
23109 spotdir = left; break;
23110 case left:
23111 spotdir = down; break;
23112 }
23113 break;
23114 case cMIRRORBACKSLASH:
23115 switch(spotdir)
23116 {
23117 case up:
23118 spotdir = left; break;
23119 case left:
23120 spotdir = up; break;
23121 case down:
23122 spotdir = right; break;
23123 case right:
23124 spotdir = down; break;
23125 }
23126 break;
23127 case cMAGICPRISM:
23128 for(byte d = 0; d < 4; ++d)
23129 {
23130 if(d == oppositeDir[spotdir]) continue;
23131 handleFFBeam(grid, age, d, curxy, set, block, refl, beamwid);
23132 }
23133 return;
23134 case cMAGICPRISM4:
23135 for(byte d = 0; d < 4; ++d)
23136 {
23137 handleFFBeam(grid, age, d, curxy, set, block, refl, beamwid);
23138 }
23139 return;
23140 case cMIRRORNEW:
23141 {
23142 auto cid = customTypeMap[curpos];
23143 if(unsigned(cid) >= MAXCOMBOS) break;
23144 newcombo const& cmb = combobuf[cid];
23145 byte newdir = cmb.attribytes[spotdir];
23146 if(newdir > 3) break;
23147 spotdir = newdir;
23148 break;
23149 }
23150 }
23151 }
23152 }
23153
23154 #define BEAMID_COLOR0 (1<<24) //must have rightmost 24 bits empty
23155 14283 static int get_beamid(newcombo const& cmb)
23156 {
23157 //Positive ID is a tile, negative is a color trio. 0 is nil in either case.
23158
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 13049 times.
14283 if(cmb.usrflags&cflag1) //use tile/cset style
23159 1234 return std::max(0,cmb.attributes[0]/10000)|(cmb.attribytes[1]%12)<<24;
23160 else //use 3-color style
23161 {
23162 13049 auto id = -((cmb.attribytes[3]<<16)|(cmb.attribytes[2]<<8)|(cmb.attribytes[1]));
23163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13049 times.
13049 if(!id) //0 would clash with the tile/cset style
23164 id = BEAMID_COLOR0;
23165 13049 return id;
23166 }
23167 14283 }
23168 14283 static bool launch_lightbeam(newcombo const& cmb, int32_t pos,
23169 std::map<int32_t, spot_t*>& maps, bool refl, bool block)
23170 {
23171 14283 int32_t id = get_beamid(cmb);
23172 //Get the grid array for this tile/color
23173 spot_t* grid;
23174
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 if(maps[id])
23175 grid = maps[id];
23176 else
23177 {
23178 14283 grid = new spot_t[176];
23179 14283 memset(grid, 0, sizeof(spot_t)*176);
23180 14283 maps[id] = grid;
23181 }
23182 14283 byte spotdir = cmb.attribytes[0];
23183
2/2
✓ Branch 0 taken 3861 times.
✓ Branch 1 taken 10422 times.
14283 if(spotdir > 3)
23184 {
23185 10422 grid[pos] |= SP_VISITED;
23186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10422 times.
10422 istrig[pos] |= cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
23187 10422 }
23188
4/4
✓ Branch 0 taken 10892 times.
✓ Branch 1 taken 3391 times.
✓ Branch 2 taken 8090 times.
✓ Branch 3 taken 2802 times.
14283 if(refl && pos == heropos)
23189 {
23190 2802 spotdir = Hero.getDir();
23191 2802 }
23192 14283 handleBeam(grid, 0, spotdir, pos, cmb.attribytes[4], block, refl);
23193 14283 return true;
23194 }
23195
23196 static bool launch_fflightbeam(ffcdata const& ffc,
23197 std::map<int32_t, std::map<dword,spot_t>>& ffmaps, bool refl, bool block)
23198 {
23199 newcombo const& cmb = combobuf[ffc.data];
23200 int32_t id = get_beamid(cmb);
23201 //Get the grid array for this tile/color
23202 std::map<dword,spot_t>& grid = ffmaps[id]; // grid of (x<<16)|(y&0xFFFF)
23203 byte spotdir = cmb.attribytes[0];
23204 lightbeam_xy sxy(ffc.x+(ffc.hit_width/2), ffc.y+(ffc.hit_height/2));
23205 if(spotdir > 3 && sxy.valid())
23206 {
23207 grid[sxy.ffpos()] |= SP_VISITED;
23208 int32_t trigflag = cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
23209 istrig[sxy.pos()] |= trigflag;
23210 }
23211 auto beamwid = cmb.attribytes[5] < 1 ? 8 : cmb.attribytes[5];
23212 if(refl && heropos > -1 && sxy.herocollide(beamwid))
23213 {
23214 spotdir = Hero.getDir();
23215 }
23216 switch(spotdir)
23217 {
23218 case up:
23219 sxy.y = zc_min(175,sxy.y);
23220 break;
23221 case down:
23222 sxy.y = zc_max(0,sxy.y);
23223 break;
23224 case left:
23225 sxy.x = zc_min(255,sxy.x);
23226 break;
23227 case right:
23228 sxy.x = zc_max(0,sxy.x);
23229 break;
23230 }
23231 handleFFBeam(grid, 0, spotdir, sxy, cmb.attribytes[4], block, refl, beamwid);
23232 return true;
23233 }
23234
23235 14283 static BITMAP* generate_beam_bitmap(int32_t id)
23236 {
23237 14283 BITMAP* cbmp = create_bitmap_ex(8, 16*beamoffs_max, 16);
23238 14283 clear_bitmap(cbmp);
23239
3/4
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 13049 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1234 times.
14283 if(id < 0 || id == BEAMID_COLOR0)
23240 {
23241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13049 times.
13049 int cid = (id == BEAMID_COLOR0) ? 0 : abs(id);
23242 13049 byte c_inner = (cid & 0x0000FF);
23243 13049 byte c_middle = (cid & 0x00FF00)>>8;
23244 13049 byte c_outter = (cid & 0xFF0000)>>16;
23245
2/2
✓ Branch 0 taken 195735 times.
✓ Branch 1 taken 13049 times.
208784 for(size_t q = 1; q < beamoffs_max; ++q)
23246 {
23247 195735 circlefill(cbmp, 16*q+8, 8, 3, c_outter);
23248 195735 circlefill(cbmp, 16*q+7, 8, 3, c_outter);
23249 195735 circlefill(cbmp, 16*q+8, 7, 3, c_outter);
23250 195735 circlefill(cbmp, 16*q+7, 7, 3, c_outter);
23251 195735 circlefill(cbmp, 16*q+8, 8, 1, c_middle);
23252 195735 circlefill(cbmp, 16*q+7, 8, 1, c_middle);
23253 195735 circlefill(cbmp, 16*q+8, 7, 1, c_middle);
23254 195735 circlefill(cbmp, 16*q+7, 7, 1, c_middle);
23255 195735 circlefill(cbmp, 16*q+8, 8, 0, c_inner);
23256 195735 circlefill(cbmp, 16*q+7, 8, 0, c_inner);
23257 195735 circlefill(cbmp, 16*q+8, 7, 0, c_inner);
23258 195735 circlefill(cbmp, 16*q+7, 7, 0, c_inner);
23259 195735 }
23260 //beamoffs_gr
23261 13049 circlefill(cbmp, 16*beamoffs_gr+8, 8, 7, c_outter);
23262 13049 circlefill(cbmp, 16*beamoffs_gr+7, 8, 7, c_outter);
23263 13049 circlefill(cbmp, 16*beamoffs_gr+8, 7, 7, c_outter);
23264 13049 circlefill(cbmp, 16*beamoffs_gr+7, 7, 7, c_outter);
23265 13049 circlefill(cbmp, 16*beamoffs_gr+8, 8, 5, c_middle);
23266 13049 circlefill(cbmp, 16*beamoffs_gr+7, 8, 5, c_middle);
23267 13049 circlefill(cbmp, 16*beamoffs_gr+8, 7, 5, c_middle);
23268 13049 circlefill(cbmp, 16*beamoffs_gr+7, 7, 5, c_middle);
23269 13049 circlefill(cbmp, 16*beamoffs_gr+8, 8, 3, c_inner);
23270 13049 circlefill(cbmp, 16*beamoffs_gr+7, 8, 3, c_inner);
23271 13049 circlefill(cbmp, 16*beamoffs_gr+8, 7, 3, c_inner);
23272 13049 circlefill(cbmp, 16*beamoffs_gr+7, 7, 3, c_inner);
23273 //beamoffs_up
23274 13049 rectfill(cbmp, 16*beamoffs_up+4, 0, 16*beamoffs_up+11, 7, c_outter);
23275 13049 rectfill(cbmp, 16*beamoffs_up+6, 0, 16*beamoffs_up+9, 7, c_middle);
23276 13049 rectfill(cbmp, 16*beamoffs_up+7, 0, 16*beamoffs_up+8, 7, c_inner);
23277 //beamoffs_down
23278 13049 rectfill(cbmp, 16*beamoffs_down+4, 8, 16*beamoffs_down+11, 15, c_outter);
23279 13049 rectfill(cbmp, 16*beamoffs_down+6, 8, 16*beamoffs_down+9, 15, c_middle);
23280 13049 rectfill(cbmp, 16*beamoffs_down+7, 8, 16*beamoffs_down+8, 15, c_inner);
23281 //beamoffs_left
23282 13049 rectfill(cbmp, 16*beamoffs_left, 4, 16*beamoffs_left+7, 11, c_outter);
23283 13049 rectfill(cbmp, 16*beamoffs_left, 6, 16*beamoffs_left+7, 9, c_middle);
23284 13049 rectfill(cbmp, 16*beamoffs_left, 7, 16*beamoffs_left+7, 8, c_inner);
23285 //beamoffs_right
23286 13049 rectfill(cbmp, 16*beamoffs_right+8, 4, 16*beamoffs_right+15, 11, c_outter);
23287 13049 rectfill(cbmp, 16*beamoffs_right+8, 6, 16*beamoffs_right+15, 9, c_middle);
23288 13049 rectfill(cbmp, 16*beamoffs_right+8, 7, 16*beamoffs_right+15, 8, c_inner);
23289 //beamoffs_uleft
23290 13049 rectfill(cbmp, 16*beamoffs_uleft+4, 0, 16*beamoffs_uleft+11, 7, c_outter);
23291 13049 rectfill(cbmp, 16*beamoffs_uleft, 4, 16*beamoffs_uleft+7, 11, c_outter);
23292 13049 rectfill(cbmp, 16*beamoffs_uleft, 6, 16*beamoffs_uleft+7, 9, c_middle);
23293 13049 rectfill(cbmp, 16*beamoffs_uleft+6, 0, 16*beamoffs_uleft+9, 7, c_middle);
23294 13049 rectfill(cbmp, 16*beamoffs_uleft+7, 0, 16*beamoffs_uleft+8, 7, c_inner);
23295 13049 rectfill(cbmp, 16*beamoffs_uleft, 7, 16*beamoffs_uleft+7, 8, c_inner);
23296 //beamoffs_uright
23297 13049 rectfill(cbmp, 16*beamoffs_uright+4, 0, 16*beamoffs_uright+11, 7, c_outter);
23298 13049 rectfill(cbmp, 16*beamoffs_uright+8, 4, 16*beamoffs_uright+15, 11, c_outter);
23299 13049 rectfill(cbmp, 16*beamoffs_uright+8, 6, 16*beamoffs_uright+15, 9, c_middle);
23300 13049 rectfill(cbmp, 16*beamoffs_uright+6, 0, 16*beamoffs_uright+9, 7, c_middle);
23301 13049 rectfill(cbmp, 16*beamoffs_uright+7, 0, 16*beamoffs_uright+8, 7, c_inner);
23302 13049 rectfill(cbmp, 16*beamoffs_uright+8, 7, 16*beamoffs_uright+15, 8, c_inner);
23303 //beamoffs_dleft
23304 13049 rectfill(cbmp, 16*beamoffs_dleft+4, 8, 16*beamoffs_dleft+11, 15, c_outter);
23305 13049 rectfill(cbmp, 16*beamoffs_dleft, 4, 16*beamoffs_dleft+7, 11, c_outter);
23306 13049 rectfill(cbmp, 16*beamoffs_dleft, 6, 16*beamoffs_dleft+7, 9, c_middle);
23307 13049 rectfill(cbmp, 16*beamoffs_dleft+6, 8, 16*beamoffs_dleft+9, 15, c_middle);
23308 13049 rectfill(cbmp, 16*beamoffs_dleft+7, 8, 16*beamoffs_dleft+8, 15, c_inner);
23309 13049 rectfill(cbmp, 16*beamoffs_dleft, 7, 16*beamoffs_dleft+7, 8, c_inner);
23310 //beamoffs_dright
23311 13049 rectfill(cbmp, 16*beamoffs_dright+4, 8, 16*beamoffs_dright+11, 15, c_outter);
23312 13049 rectfill(cbmp, 16*beamoffs_dright+8, 4, 16*beamoffs_dright+15, 11, c_outter);
23313 13049 rectfill(cbmp, 16*beamoffs_dright+8, 6, 16*beamoffs_dright+15, 9, c_middle);
23314 13049 rectfill(cbmp, 16*beamoffs_dright+6, 8, 16*beamoffs_dright+9, 15, c_middle);
23315 13049 rectfill(cbmp, 16*beamoffs_dright+7, 8, 16*beamoffs_dright+8, 15, c_inner);
23316 13049 rectfill(cbmp, 16*beamoffs_dright+8, 7, 16*beamoffs_dright+15, 8, c_inner);
23317 //beamoffs_vert
23318 13049 rectfill(cbmp, 16*beamoffs_vert+4, 0, 16*beamoffs_vert+11, 15, c_outter);
23319 13049 rectfill(cbmp, 16*beamoffs_vert+6, 0, 16*beamoffs_vert+9, 15, c_middle);
23320 13049 rectfill(cbmp, 16*beamoffs_vert+7, 0, 16*beamoffs_vert+8, 15, c_inner);
23321 //beamoffs_horz
23322 13049 rectfill(cbmp, 16*beamoffs_horz, 4, 16*beamoffs_horz+15, 11, c_outter);
23323 13049 rectfill(cbmp, 16*beamoffs_horz, 6, 16*beamoffs_horz+15, 9, c_middle);
23324 13049 rectfill(cbmp, 16*beamoffs_horz, 7, 16*beamoffs_horz+15, 8, c_inner);
23325 //beamoffs_notup
23326 13049 rectfill(cbmp, 16*beamoffs_notup, 4, 16*beamoffs_notup+15, 11, c_outter);
23327 13049 rectfill(cbmp, 16*beamoffs_notup+4, 8, 16*beamoffs_notup+11, 15, c_outter);
23328 13049 rectfill(cbmp, 16*beamoffs_notup+6, 8, 16*beamoffs_notup+9, 15, c_middle);
23329 13049 rectfill(cbmp, 16*beamoffs_notup, 6, 16*beamoffs_notup+15, 9, c_middle);
23330 13049 rectfill(cbmp, 16*beamoffs_notup, 7, 16*beamoffs_notup+15, 8, c_inner);
23331 13049 rectfill(cbmp, 16*beamoffs_notup+7, 8, 16*beamoffs_notup+8, 15, c_inner);
23332 //beamoffs_notdown
23333 13049 rectfill(cbmp, 16*beamoffs_notdown, 4, 16*beamoffs_notdown+15, 11, c_outter);
23334 13049 rectfill(cbmp, 16*beamoffs_notdown+4, 0, 16*beamoffs_notdown+11, 7, c_outter);
23335 13049 rectfill(cbmp, 16*beamoffs_notdown+6, 0, 16*beamoffs_notdown+9, 7, c_middle);
23336 13049 rectfill(cbmp, 16*beamoffs_notdown, 6, 16*beamoffs_notdown+15, 9, c_middle);
23337 13049 rectfill(cbmp, 16*beamoffs_notdown, 7, 16*beamoffs_notdown+15, 8, c_inner);
23338 13049 rectfill(cbmp, 16*beamoffs_notdown+7, 0, 16*beamoffs_notdown+8, 7, c_inner);
23339 //beamoffs_notleft
23340 13049 rectfill(cbmp, 16*beamoffs_notleft+4, 0, 16*beamoffs_notleft+11, 15, c_outter);
23341 13049 rectfill(cbmp, 16*beamoffs_notleft+8, 4, 16*beamoffs_notleft+15, 11, c_outter);
23342 13049 rectfill(cbmp, 16*beamoffs_notleft+8, 6, 16*beamoffs_notleft+15, 9, c_middle);
23343 13049 rectfill(cbmp, 16*beamoffs_notleft+6, 0, 16*beamoffs_notleft+9, 15, c_middle);
23344 13049 rectfill(cbmp, 16*beamoffs_notleft+7, 0, 16*beamoffs_notleft+8, 15, c_inner);
23345 13049 rectfill(cbmp, 16*beamoffs_notleft+8, 7, 16*beamoffs_notleft+15, 8, c_inner);
23346 //beamoffs_notright
23347 13049 rectfill(cbmp, 16*beamoffs_notright+4, 0, 16*beamoffs_notright+11, 15, c_outter);
23348 13049 rectfill(cbmp, 16*beamoffs_notright, 4, 16*beamoffs_notright+7, 11, c_outter);
23349 13049 rectfill(cbmp, 16*beamoffs_notright, 6, 16*beamoffs_notright+7, 9, c_middle);
23350 13049 rectfill(cbmp, 16*beamoffs_notright+6, 0, 16*beamoffs_notright+9, 15, c_middle);
23351 13049 rectfill(cbmp, 16*beamoffs_notright+7, 0, 16*beamoffs_notright+8, 15, c_inner);
23352 13049 rectfill(cbmp, 16*beamoffs_notright, 7, 16*beamoffs_notright+7, 8, c_inner);
23353 //beamoffs_all
23354 13049 rectfill(cbmp, 16*beamoffs_all+4, 0, 16*beamoffs_all+11, 15, c_outter);
23355 13049 rectfill(cbmp, 16*beamoffs_all, 4, 16*beamoffs_all+15, 11, c_outter);
23356 13049 rectfill(cbmp, 16*beamoffs_all, 6, 16*beamoffs_all+15, 9, c_middle);
23357 13049 rectfill(cbmp, 16*beamoffs_all+6, 0, 16*beamoffs_all+9, 15, c_middle);
23358 13049 rectfill(cbmp, 16*beamoffs_all+7, 0, 16*beamoffs_all+8, 15, c_inner);
23359 13049 rectfill(cbmp, 16*beamoffs_all, 7, 16*beamoffs_all+15, 8, c_inner);
23360 13049 }
23361 else
23362 {
23363 1234 int32_t tile = (id&0xFFFFFF);
23364 1234 int32_t cs = (id>>24);
23365
2/2
✓ Branch 0 taken 19744 times.
✓ Branch 1 taken 1234 times.
20978 for(size_t q = 0; q < beamoffs_max; ++q)
23366 19744 puttile16(cbmp, tile+q, q*16, 0, cs, 0);
23367 }
23368 14283 return cbmp;
23369 }
23370
23371 2513808 static int32_t get_beamoffs(spot_t val)
23372 {
23373
12/17
✗ Branch 0 not taken.
✓ Branch 1 taken 2444313 times.
✓ Branch 2 taken 1469 times.
✓ Branch 3 taken 1188 times.
✓ Branch 4 taken 1795 times.
✓ Branch 5 taken 1768 times.
✓ Branch 6 taken 14821 times.
✓ Branch 7 taken 31678 times.
✓ Branch 8 taken 4877 times.
✓ Branch 9 taken 3412 times.
✓ Branch 10 taken 4161 times.
✓ Branch 11 taken 3791 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 535 times.
2513808 switch((val&SP_MASK)>>1)
23374 {
23375 2444313 case 0: default:
23376
2/2
✓ Branch 0 taken 7620 times.
✓ Branch 1 taken 2436693 times.
2444313 if(val)
23377 7620 return beamoffs_gr;
23378 2436693 return -1;
23379 case 0b0001:
23380 1469 return beamoffs_up;
23381 case 0b0010:
23382 1188 return beamoffs_down;
23383 case 0b0100:
23384 1795 return beamoffs_left;
23385 case 0b1000:
23386 1768 return beamoffs_right;
23387 case 0b0011:
23388 14821 return beamoffs_vert;
23389 case 0b1100:
23390 31678 return beamoffs_horz;
23391 case 0b0101:
23392 4877 return beamoffs_uleft;
23393 case 0b1001:
23394 3412 return beamoffs_uright;
23395 case 0b0110:
23396 4161 return beamoffs_dleft;
23397 case 0b1010:
23398 3791 return beamoffs_dright;
23399 case 0b1110:
23400 return beamoffs_notup;
23401 case 0b1101:
23402 return beamoffs_notdown;
23403 case 0b1011:
23404 return beamoffs_notleft;
23405 case 0b0111:
23406 return beamoffs_notright;
23407 case 0b1111:
23408 535 return beamoffs_all;
23409 }
23410 return -1;
23411 2513808 }
23412
23413 14168556 void HeroClass::handleSpotlights()
23414 {
23415 static bool had_spotlight = true;
23416 14168556 word c = tmpscr->numFFC();
23417
2/2
✓ Branch 0 taken 14283 times.
✓ Branch 1 taken 14154273 times.
14168556 if(cpos_exists_spotlight())
23418 {
23419 //Store each different tile/color as grids
23420 14283 std::map<int32_t, spot_t*> maps;
23421 14283 std::map<int32_t, std::map<dword, spot_t>> ffmaps;
23422
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 int32_t shieldid = getCurrentShield(false);
23423
2/8
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14283 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14283 if((itemsbuf[shieldid].flags & item_flag9) && !usingActiveShield(shieldid))
23424 shieldid = -1;
23425
2/2
✓ Branch 0 taken 3391 times.
✓ Branch 1 taken 10892 times.
14283 bool refl = shieldid > -1 && (itemsbuf[shieldid].misc2 & sh_lightbeam);
23426
3/4
✓ Branch 0 taken 3391 times.
✓ Branch 1 taken 10892 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3391 times.
14283 bool block = !refl && shieldid > -1 && (itemsbuf[shieldid].misc1 & sh_lightbeam);
23427
3/6
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14283 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14283 times.
✗ Branch 5 not taken.
14283 heropos = COMBOPOS_B(x.getInt()+8,y.getInt()+8);
23428 14283 memset(istrig, 0, sizeof(istrig));
23429
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 clear_bitmap(lightbeam_bmp);
23430
23431
2/2
✓ Branch 0 taken 2513808 times.
✓ Branch 1 taken 14283 times.
2528091 for(size_t pos = 0; pos < 176; ++pos)
23432 {
23433 2513808 typeMap[pos] = 0;
23434 2513808 customTypeMap[pos] = -1;
23435
2/2
✓ Branch 0 taken 2334689 times.
✓ Branch 1 taken 17592933 times.
19927622 for(int32_t lyr = 6; lyr > -1; --lyr)
23436 {
23437 17592933 auto cid = FFCore.tempScreens[lyr]->data[pos];
23438 17592933 newcombo const* cmb = &combobuf[cid];
23439
3/4
✓ Branch 0 taken 175417 times.
✓ Branch 1 taken 17413814 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3702 times.
17592933 switch(cmb->type)
23440 {
23441 case cMIRROR: case cMIRRORSLASH: case cMIRRORBACKSLASH:
23442 case cMAGICPRISM: case cMAGICPRISM4:
23443 case cBLOCKALL: case cLIGHTTARGET:
23444 175417 typeMap[pos] = cmb->type;
23445 175417 break;
23446 case cMIRRORNEW:
23447 typeMap[pos] = cMIRRORNEW;
23448 customTypeMap[pos] = cid;
23449 break;
23450 case cGLASS:
23451 3702 typeMap[pos] = 0;
23452 3702 break;
23453 default:
23454 {
23455
4/4
✓ Branch 0 taken 7358582 times.
✓ Branch 1 taken 10055232 times.
✓ Branch 2 taken 6017045 times.
✓ Branch 3 taken 1341537 times.
17413814 if(lyr < 3 && (cmb->walk & 0xF))
23456 {
23457 1341537 typeMap[pos] = SPTYPE_SOLID;
23458 1341537 }
23459 17413814 continue; //next layer
23460 }
23461 }
23462 179119 break; //hit a combo type
23463 }
23464
4/4
✓ Branch 0 taken 2296624 times.
✓ Branch 1 taken 217184 times.
✓ Branch 2 taken 1421859 times.
✓ Branch 3 taken 874765 times.
2513808 if(!get_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ) && !typeMap[pos])
23465 {
23466
8/16
✓ Branch 0 taken 874765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 874765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 874765 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 874765 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 874765 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 874765 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 874765 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 874765 times.
✗ Branch 15 not taken.
874765 if(collide_object(COMBOX(pos),COMBOY(pos),16,16,this))
23467 typeMap[pos] = SPTYPE_SOLID;
23468 874765 }
23469 2513808 }
23470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14283 times.
14283 if(unsigned(heropos) < 176)
23471 {
23472
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14031 times.
14283 switch(typeMap[heropos])
23473 {
23474 case SPTYPE_SOLID: case cBLOCKALL:
23475 252 heropos = -1; //Blocked from hitting player
23476 252 }
23477 14283 }
23478
23479
2/2
✓ Branch 0 taken 99981 times.
✓ Branch 1 taken 14283 times.
114264 for(size_t layer = 0; layer < 7; ++layer)
23480 {
23481 99981 mapscr* curlayer = FFCore.tempScreens[layer];
23482
2/2
✓ Branch 0 taken 17596656 times.
✓ Branch 1 taken 99981 times.
17696637 for(size_t pos = 0; pos < 176; ++pos)
23483 {
23484 17596656 newcombo const& cmb = combobuf[curlayer->data[pos]];
23485
2/2
✓ Branch 0 taken 17582373 times.
✓ Branch 1 taken 14283 times.
17596656 if(cmb.type == cSPOTLIGHT)
23486
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 launch_lightbeam(cmb,pos,maps,refl,block);
23487 17596656 }
23488 99981 }
23489
2/2
✓ Branch 0 taken 16751 times.
✓ Branch 1 taken 14283 times.
31034 for(word i=0; i<c; i++)
23490 {
23491 16751 ffcdata& ffc = tmpscr->ffcs[i];
23492
3/6
✓ Branch 0 taken 16751 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16751 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 16751 times.
16751 if(ffc.flags & (ffc_changer|ffc_ethereal))
23493 continue;
23494 16751 newcombo const& cmb = combobuf[ffc.data];
23495
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16751 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16751 if(cmb.type == cSPOTLIGHT && (cmb.usrflags&cflag2))
23496 launch_fflightbeam(ffc,ffmaps,refl,block);
23497 16751 }
23498
23499
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 lightbeam_present = !maps.empty() || !ffmaps.empty();
23500
23501 //Draw visuals
23502
2/2
✓ Branch 0 taken 14283 times.
✓ Branch 1 taken 14283 times.
28566 for(auto it = maps.begin(); it != maps.end();)
23503 {
23504 14283 int32_t id = it->first;
23505 14283 spot_t* grid = it->second;
23506
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 BITMAP* cbmp = generate_beam_bitmap(id);
23507
2/2
✓ Branch 0 taken 14283 times.
✓ Branch 1 taken 2513808 times.
2528091 for(size_t pos = 0; pos < 176; ++pos)
23508 {
23509
1/2
✓ Branch 0 taken 2513808 times.
✗ Branch 1 not taken.
2513808 int32_t offs = get_beamoffs(grid[pos]);
23510
2/2
✓ Branch 0 taken 77115 times.
✓ Branch 1 taken 2436693 times.
2513808 if(offs > -1)
23511
3/6
✓ Branch 0 taken 77115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77115 times.
✗ Branch 5 not taken.
77115 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, COMBOX(pos), COMBOY(pos), 16, 16);
23512 2513808 }
23513
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 destroy_bitmap(cbmp);
23514
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 delete[] it->second;
23515
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 it = maps.erase(it);
23516 }
23517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14283 times.
14283 for(auto it = ffmaps.begin(); it != ffmaps.end();)
23518 {
23519 int32_t id = it->first;
23520 std::map<dword,spot_t> const& grid = it->second;
23521 BITMAP* cbmp = generate_beam_bitmap(id);
23522 for(auto it2 = grid.begin(); it2 != grid.end(); ++it2)
23523 {
23524 lightbeam_xy ffxy(it2->first);
23525 int32_t offs = get_beamoffs(it2->second);
23526 if(offs > -1)
23527 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, ffxy.x-8, ffxy.y-8, 16, 16);
23528 }
23529 destroy_bitmap(cbmp);
23530 it = ffmaps.erase(it);
23531 }
23532 14283 }
23533 else
23534 {
23535
2/2
✓ Branch 0 taken 14154009 times.
✓ Branch 1 taken 264 times.
14154273 if(had_spotlight)
23536 {
23537 264 memset(istrig, 0, sizeof(istrig));
23538 264 clear_bitmap(lightbeam_bmp);
23539 264 }
23540 14154273 lightbeam_present = false;
23541 }
23542 14168556 had_spotlight = lightbeam_present;
23543 //Check triggers
23544 14168556 bool hastrigs = false, istrigged = true;
23545 14168556 bool alltrig = getmapflag(mLIGHTBEAM);
23546
2/2
✓ Branch 0 taken 99179892 times.
✓ Branch 1 taken 14168556 times.
113348448 for(size_t layer = 0; layer < 7; ++layer)
23547 {
23548 99179892 mapscr* curlayer = FFCore.tempScreens[layer];
23549
2/2
✓ Branch 0 taken 17455660992 times.
✓ Branch 1 taken 99179892 times.
17554840884 for(size_t pos = 0; pos < 176; ++pos)
23550 {
23551 17455660992 newcombo const* cmb = &combobuf[curlayer->data[pos]];
23552
2/2
✓ Branch 0 taken 13121 times.
✓ Branch 1 taken 17455647871 times.
17455660992 if(cmb->type == cLIGHTTARGET)
23553 {
23554
2/2
✓ Branch 0 taken 11887 times.
✓ Branch 1 taken 1234 times.
13121 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
23555 13121 hastrigs = true;
23556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13121 times.
13121 bool trigged = lightbeam_present && (istrig[pos]&trigflag);
23557
1/2
✓ Branch 0 taken 13121 times.
✗ Branch 1 not taken.
13121 if(cmb->usrflags&cflag2) //Invert
23558 trigged = !trigged;
23559
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 12872 times.
13121 if(cmb->usrflags&cflag1) //Solved Version
23560 {
23561
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
23562 {
23563 curlayer->data[pos] -= 1;
23564 istrigged = false;
23565 }
23566 249 }
23567 else //Unsolved version
23568 {
23569
3/4
✓ Branch 0 taken 12872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 12868 times.
12872 if(alltrig || trigged) //Light
23570 4 curlayer->data[pos] += 1;
23571 12868 else istrigged = false;
23572 }
23573 13121 }
23574
2/2
✓ Branch 0 taken 17455644169 times.
✓ Branch 1 taken 3702 times.
17455647871 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
23575 {
23576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3702 times.
3702 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
23577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3702 times.
3702 bool trigged = lightbeam_present && (istrig[pos]&trigflag);
23578
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 3597 times.
✓ Branch 2 taken 3696 times.
✓ Branch 3 taken 6 times.
3702 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
23579 3597 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
23580 {
23581 6 do_trigger_combo(layer, pos);
23582 6 }
23583 3702 }
23584 17455660992 }
23585 99179892 }
23586
2/2
✓ Branch 0 taken 424282463 times.
✓ Branch 1 taken 14168556 times.
438451019 for(word i=0; i<c; i++)
23587 {
23588 424282463 ffcdata& ffc = tmpscr->ffcs[i];
23589 424282463 newcombo const* cmb = &combobuf[ffc.data];
23590
2/2
✓ Branch 0 taken 423304889 times.
✓ Branch 1 taken 977574 times.
424282463 size_t pos = get_qr(qr_BROKEN_LIGHTBEAM_HITBOX)
23591 423304889 ? COMBOPOS(ffc.x+8, ffc.y+8)
23592 977574 : COMBOPOS(ffc.x+(ffc.hit_width/2), ffc.y+(ffc.hit_height/2));
23593
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 424281229 times.
424282463 if(cmb->type == cLIGHTTARGET)
23594 {
23595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
23596 1234 hastrigs = true;
23597 1234 bool trigged = (istrig[pos]&trigflag);
23598
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(cmb->usrflags&cflag2) //Invert
23599 trigged = !trigged;
23600
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 985 times.
1234 if(cmb->usrflags&cflag1) //Solved Version
23601 {
23602
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
23603 {
23604 zc_ffc_modify(ffc, -1);
23605 istrigged = false;
23606 }
23607 249 }
23608 else //Unsolved version
23609 {
23610
3/4
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 984 times.
985 if(alltrig || trigged) //Light
23611 1 zc_ffc_modify(ffc, 1);
23612 984 else istrigged = false;
23613 }
23614 1234 }
23615
2/2
✓ Branch 0 taken 424278761 times.
✓ Branch 1 taken 2468 times.
424281229 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
23616 {
23617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2468 times.
2468 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
23618 2468 bool trigged = (istrig[pos]&trigflag);
23619
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2406 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2464 times.
2468 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
23620 2406 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
23621 {
23622 4 do_trigger_combo_ffc(i);
23623 4 }
23624 2468 }
23625 424282463 }
23626
6/6
✓ Branch 0 taken 13121 times.
✓ Branch 1 taken 14155435 times.
✓ Branch 2 taken 253 times.
✓ Branch 3 taken 12868 times.
✓ Branch 4 taken 249 times.
✓ Branch 5 taken 4 times.
14168556 if(hastrigs && istrigged && !alltrig)
23627 {
23628 4 hidden_entrance(0,true,false,-7);
23629 4 sfx(tmpscr->secretsfx);
23630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!(tmpscr->flags5&fTEMPSECRETS))
23631 {
23632 4 setmapflag(mSECRET);
23633 4 setmapflag(mLIGHTBEAM);
23634 4 }
23635 4 }
23636 14168556 }
23637
23638 14146038 void HeroClass::checktouchblk()
23639 {
23640
2/2
✓ Branch 0 taken 14694 times.
✓ Branch 1 taken 14131344 times.
14146038 if(toogam) return;
23641
23642
2/2
✓ Branch 0 taken 947151 times.
✓ Branch 1 taken 13184193 times.
14131344 if(!pushing)
23643 13184193 return;
23644
23645 947151 int32_t tdir = dir; //Bad hack #2. _L_, your welcome to fix this properly. ;)
23646
23647
4/4
✓ Branch 0 taken 938375 times.
✓ Branch 1 taken 8776 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 938279 times.
947151 if(charging > 0 || spins > 0) //if not I probably will at some point...
23648 {
23649
4/4
✓ Branch 0 taken 4072 times.
✓ Branch 1 taken 4800 times.
✓ Branch 2 taken 2940 times.
✓ Branch 3 taken 1132 times.
8872 if(Up()&&Left())tdir = (charging%2)*2;
23650
4/4
✓ Branch 0 taken 2940 times.
✓ Branch 1 taken 4800 times.
✓ Branch 2 taken 1410 times.
✓ Branch 3 taken 1530 times.
7740 else if(Up()&&Right())tdir = (charging%2)*3;
23651
4/4
✓ Branch 0 taken 2544 times.
✓ Branch 1 taken 3666 times.
✓ Branch 2 taken 1681 times.
✓ Branch 3 taken 863 times.
6210 else if(Down()&&Left())tdir = 1+(charging%2)*1;
23652
4/4
✓ Branch 0 taken 1681 times.
✓ Branch 1 taken 3666 times.
✓ Branch 2 taken 869 times.
✓ Branch 3 taken 812 times.
5347 else if(Down()&&Right())tdir = 1+(charging%2)*2;
23653 else
23654 {
23655
2/2
✓ Branch 0 taken 1410 times.
✓ Branch 1 taken 3125 times.
4535 if(Up())tdir=0;
23656
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 2261 times.
3125 else if(Down())tdir=1;
23657
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 1382 times.
2261 else if(Left())tdir=2;
23658
1/2
✓ Branch 0 taken 1382 times.
✗ Branch 1 not taken.
1382 else if(Right())tdir=3;
23659 }
23660 8872 }
23661
23662 947151 int32_t tx=0,ty=-1;
23663
23664
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 234357 times.
✓ Branch 2 taken 212351 times.
✓ Branch 3 taken 233425 times.
✓ Branch 4 taken 267018 times.
947151 switch(tdir)
23665 {
23666 case up:
23667
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 234136 times.
234357 if(touchcombo(x,y+(bigHitbox?0:7)))
23668 {
23669 221 tx=x;
23670 221 ty=y+(bigHitbox?0:7);
23671 221 }
23672
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 234111 times.
234136 else if(touchcombo(x+8,y+(bigHitbox?0:7)))
23673 {
23674 25 tx=x+8;
23675 25 ty=y+(bigHitbox?0:7);
23676 25 }
23677
23678 234357 break;
23679
23680 case down:
23681
2/2
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 210702 times.
212351 if(touchcombo(x,y+16))
23682 {
23683 1649 tx=x;
23684 1649 ty=y+16;
23685 1649 }
23686
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 210438 times.
210702 else if(touchcombo(x+8,y+16))
23687 {
23688 264 tx=x+8;
23689 264 ty=y+16;
23690 264 }
23691
23692 212351 break;
23693
23694 case left:
23695
2/2
✓ Branch 0 taken 232584 times.
✓ Branch 1 taken 841 times.
233425 if(touchcombo(x-1,y+15))
23696 {
23697 841 tx=x-1;
23698 841 ty=y+15;
23699 841 }
23700
23701 233425 break;
23702
23703 case right:
23704
2/2
✓ Branch 0 taken 265836 times.
✓ Branch 1 taken 1182 times.
267018 if(touchcombo(x+16,y+15))
23705 {
23706 1182 tx=x+16;
23707 1182 ty=y+15;
23708 1182 }
23709
23710 267018 break;
23711 }
23712
23713
2/2
✓ Branch 0 taken 942969 times.
✓ Branch 1 taken 4182 times.
947151 if(ty>=0)
23714 {
23715 4182 ty&=0xF0;
23716 4182 tx&=0xF0;
23717 4182 int32_t di = ty+(tx>>4);
23718
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4182 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4182 if((getAction() != hopping || isSideViewHero()))
23719 {
23720 4182 trigger_armos_grave(0, di, dir);
23721 4182 }
23722 4182 }
23723 14146038 }
23724
23725 int32_t HeroClass::nextcombo(int32_t cx, int32_t cy, int32_t cdir)
23726 {
23727 switch(cdir)
23728 {
23729 case up:
23730 cy-=16;
23731 break;
23732
23733 case down:
23734 cy+=16;
23735 break;
23736
23737 case left:
23738 cx-=16;
23739 break;
23740
23741 case right:
23742 cx+=16;
23743 break;
23744 }
23745
23746 // off the screen
23747 if(cx<0 || cy<0 || cx>255 || cy>175)
23748 {
23749 int ns;
23750 if(auto scr = nextscr(cdir,false))
23751 ns = *scr;
23752 else return 0;
23753
23754 switch(cdir)
23755 {
23756 case up:
23757 cy=160;
23758 break;
23759
23760 case down:
23761 cy=0;
23762 break;
23763
23764 case left:
23765 cx=240;
23766 break;
23767
23768 case right:
23769 cx=0;
23770 break;
23771 }
23772
23773 // from MAPCOMBO()
23774 int32_t cmb = (cy&0xF0)+(cx>>4);
23775
23776 if(cmb>175)
23777 return 0;
23778
23779 return TheMaps[ns].data[cmb]; // entire combo code
23780 }
23781
23782 return MAPCOMBO(cx,cy);
23783 }
23784
23785 15867 int32_t HeroClass::nextflag(int32_t cx, int32_t cy, int32_t cdir, bool comboflag)
23786 {
23787
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3203 times.
✓ Branch 2 taken 3545 times.
✓ Branch 3 taken 3978 times.
✓ Branch 4 taken 5141 times.
15867 switch(cdir)
23788 {
23789 case up:
23790 3203 cy-=16;
23791 3203 break;
23792
23793 case down:
23794 3545 cy+=16;
23795 3545 break;
23796
23797 case left:
23798 3978 cx-=16;
23799 3978 break;
23800
23801 case right:
23802 5141 cx+=16;
23803 5141 break;
23804 }
23805
23806 // off the screen
23807
8/8
✓ Branch 0 taken 15766 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 15621 times.
✓ Branch 3 taken 145 times.
✓ Branch 4 taken 15447 times.
✓ Branch 5 taken 174 times.
✓ Branch 6 taken 192 times.
✓ Branch 7 taken 15255 times.
15867 if(cx<0 || cy<0 || cx>255 || cy>175)
23808 {
23809 int ns;
23810
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 4 times.
612 if(auto scr = nextscr(cdir,false))
23811 608 ns = *scr;
23812 4 else return 0;
23813
23814
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 101 times.
✓ Branch 4 taken 174 times.
608 switch(cdir)
23815 {
23816 case up:
23817 143 cy=160;
23818 143 break;
23819
23820 case down:
23821 190 cy=0;
23822 190 break;
23823
23824 case left:
23825 101 cx=240;
23826 101 break;
23827
23828 case right:
23829 174 cx=0;
23830 174 break;
23831 }
23832
23833 // from MAPCOMBO()
23834 608 int32_t cmb = (cy&0xF0)+(cx>>4);
23835
23836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 608 times.
608 if(cmb>175)
23837 return 0;
23838
23839
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 523 times.
608 if(!comboflag)
23840 {
23841 523 return TheMaps[ns].sflag[cmb]; // flag
23842 }
23843 else
23844 {
23845 85 return combobuf[TheMaps[ns].data[cmb]].flag; // flag
23846 }
23847 }
23848
23849
2/2
✓ Branch 0 taken 3952 times.
✓ Branch 1 taken 11303 times.
15255 if(comboflag)
23850 {
23851 3952 return MAPCOMBOFLAG(cx,cy);
23852 }
23853
23854 11303 return MAPFLAG(cx,cy);
23855 15867 }
23856
23857 bool did_secret;
23858
23859 14146038 void HeroClass::checkspecial()
23860 {
23861 14146038 checktouchblk();
23862
23863 14146038 bool hasmainguy = hasMainGuy(); // calculate it once
23864
23865
4/4
✓ Branch 0 taken 14025507 times.
✓ Branch 1 taken 120531 times.
✓ Branch 2 taken 8595483 times.
✓ Branch 3 taken 5430024 times.
14146038 if(!(loaded_enemies && !hasmainguy))
23866 8716014 did_secret=false;
23867 else
23868 {
23869 // after beating enemies
23870
23871 // generic 'Enemies->' trigger
23872
2/2
✓ Branch 0 taken 38010168 times.
✓ Branch 1 taken 5430024 times.
43440192 for(auto lyr = 0; lyr < 7; ++lyr)
23873 {
23874
2/2
✓ Branch 0 taken 6689789568 times.
✓ Branch 1 taken 38010168 times.
6727799736 for(auto pos = 0; pos < 176; ++pos)
23875 {
23876 6689789568 newcombo const& cmb = combobuf[FFCore.tempScreens[lyr]->data[pos]];
23877
2/2
✓ Branch 0 taken 6689789563 times.
✓ Branch 1 taken 5 times.
6689789568 if(cmb.triggerflags[2] & combotriggerENEMIESKILLED)
23878 {
23879 5 do_trigger_combo(lyr,pos);
23880 5 }
23881 6689789568 }
23882 38010168 }
23883 5430024 word c = tmpscr->numFFC();
23884
2/2
✓ Branch 0 taken 157843695 times.
✓ Branch 1 taken 5430024 times.
163273719 for(word i=0; i<c; i++)
23885 {
23886 157843695 ffcdata& ffc = tmpscr->ffcs[i];
23887 157843695 newcombo const& cmb = combobuf[ffc.data];
23888
1/2
✓ Branch 0 taken 157843695 times.
✗ Branch 1 not taken.
157843695 if(cmb.triggerflags[2] & combotriggerENEMIESKILLED)
23889 {
23890 do_trigger_combo_ffc(i);
23891 }
23892 157843695 }
23893
1/2
✓ Branch 0 taken 5430024 times.
✗ Branch 1 not taken.
5430024 if(tmpscr->flags9 & fENEMY_WAVES)
23894 {
23895 hasmainguy = hasMainGuy(); //possibly un-beat the enemies (another 'wave'?)
23896 }
23897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5430024 times.
5430024 if(!hasmainguy)
23898 {
23899 // item
23900
2/2
✓ Branch 0 taken 5429276 times.
✓ Branch 1 taken 748 times.
5430024 if(hasitem&(4|2|1))
23901 {
23902 748 int32_t Item=tmpscr->item;
23903
23904 //if(getmapflag())
23905 // Item=0;
23906
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 748 times.
748 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
23907 {
23908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 748 times.
748 if(hasitem==1)
23909 748 sfx(WAV_CLEARED);
23910
23911
2/4
✓ Branch 0 taken 748 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 748 times.
✗ Branch 3 not taken.
1496 items.add(new item((zfix)tmpscr->itemx,
23912
6/12
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 677 times.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 71 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 748 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 748 times.
✗ Branch 11 not taken.
748 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
23913
6/10
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 677 times.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 71 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 71 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 677 times.
✗ Branch 9 not taken.
748 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
23914
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 747 times.
748 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
23915 748 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
23916 748 }
23917
23918 748 hasitem &= ~ (4|2|1);
23919 748 }
23920 // if room has traps, guys don't come back
23921
2/2
✓ Branch 0 taken 2780172288 times.
✓ Branch 1 taken 5430024 times.
2785602312 for(int32_t i=0; i<eMAXGUYS; i++)
23922 {
23923
4/4
✓ Branch 0 taken 81025031 times.
✓ Branch 1 taken 2699147257 times.
✓ Branch 2 taken 70222189 times.
✓ Branch 3 taken 10802842 times.
2780172288 if(guysbuf[i].family==eeTRAP&&guysbuf[i].attributes[1])
23924
4/4
✓ Branch 0 taken 79095 times.
✓ Branch 1 taken 10723747 times.
✓ Branch 2 taken 78998 times.
✓ Branch 3 taken 97 times.
10802939 if(guys.idCount(i) && !getmapflag(mTMPNORET))
23925 97 setmapflag(mTMPNORET);
23926 2780172288 }
23927 // clear enemies and open secret
23928
4/4
✓ Branch 0 taken 5238731 times.
✓ Branch 1 taken 191293 times.
✓ Branch 2 taken 5237877 times.
✓ Branch 3 taken 854 times.
5430024 if(!did_secret && (tmpscr->flags2&fCLEARSECRET))
23929 {
23930 854 bool only16_31 = get_qr(qr_ENEMIES_SECRET_ONLY_16_31)?true:false;
23931 854 hidden_entrance(0,true,only16_31,-2);
23932
23933
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 749 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 100 times.
854 if(tmpscr->flags4&fENEMYSCRTPERM && canPermSecret())
23934 {
23935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
23936 100 }
23937
23938 854 sfx(tmpscr->secretsfx);
23939 854 did_secret=true;
23940 854 }
23941 5430024 }
23942 }
23943
23944 // doors
23945 14146038 bool has_shutter = false;
23946
2/2
✓ Branch 0 taken 12114180 times.
✓ Branch 1 taken 52941930 times.
65056110 for(int32_t i=0; i<4; i++)
23947
2/2
✓ Branch 0 taken 50910072 times.
✓ Branch 1 taken 2031858 times.
52941930 if(tmpscr->door[i]==dSHUTTER)
23948 {
23949 2031858 has_shutter = true;
23950
4/4
✓ Branch 0 taken 1991600 times.
✓ Branch 1 taken 40258 times.
✓ Branch 2 taken 1424 times.
✓ Branch 3 taken 1990176 times.
2031858 if(opendoors==0 && loaded_enemies)
23951 {
23952
4/4
✓ Branch 0 taken 1657895 times.
✓ Branch 1 taken 332281 times.
✓ Branch 2 taken 1655472 times.
✓ Branch 3 taken 2423 times.
1990176 if(!(tmpscr->flags&fSHUTTERS) && !hasmainguy)
23953 2423 opendoors=12;
23954 1990176 }
23955
2/2
✓ Branch 0 taken 32960 times.
✓ Branch 1 taken 8722 times.
41682 else if(opendoors<0)
23956 8722 ++opendoors;
23957
2/2
✓ Branch 0 taken 30229 times.
✓ Branch 1 taken 2731 times.
32960 else if((--opendoors)==0)
23958 2731 openshutters();
23959
23960 2031858 break;
23961 }
23962
10/10
✓ Branch 0 taken 12114180 times.
✓ Branch 1 taken 2031858 times.
✓ Branch 2 taken 11878566 times.
✓ Branch 3 taken 235614 times.
✓ Branch 4 taken 11765364 times.
✓ Branch 5 taken 113202 times.
✓ Branch 6 taken 11692844 times.
✓ Branch 7 taken 72520 times.
✓ Branch 8 taken 6585076 times.
✓ Branch 9 taken 5107768 times.
14146038 if(!has_shutter && !opendoors && loaded_enemies && !(tmpscr->flags&fSHUTTERS) && !hasmainguy)
23963 {
23964 5107768 openshutters();
23965 5107768 }
23966
23967 // set boss flag when boss is gone
23968
6/6
✓ Branch 0 taken 14025507 times.
✓ Branch 1 taken 120531 times.
✓ Branch 2 taken 204006 times.
✓ Branch 3 taken 13821501 times.
✓ Branch 4 taken 153974 times.
✓ Branch 5 taken 50032 times.
14146038 if(loaded_enemies && tmpscr->enemyflags&efBOSS && !hasmainguy)
23969 {
23970 50032 game->lvlitems[dlevel]|=liBOSS;
23971 50032 stop_sfx(tmpscr->bosssfx);
23972 50032 }
23973
23974
2/2
✓ Branch 0 taken 14069742 times.
✓ Branch 1 taken 76296 times.
14146038 if(getmapflag(mCHEST)) // if special stuff done before
23975 {
23976 76296 remove_chests((currscr>=128)?1:0);
23977 76296 }
23978
23979
2/2
✓ Branch 0 taken 14143578 times.
✓ Branch 1 taken 2460 times.
14146038 if(getmapflag(mLOCKEDCHEST)) // if special stuff done before
23980 {
23981 2460 remove_lockedchests((currscr>=128)?1:0);
23982 2460 }
23983
23984
2/2
✓ Branch 0 taken 14119837 times.
✓ Branch 1 taken 26201 times.
14146038 if(getmapflag(mBOSSCHEST)) // if special stuff done before
23985 {
23986 26201 remove_bosschests((currscr>=128)?1:0);
23987 26201 }
23988
23989 14146038 clear_xdoors((currscr>=128)?1:0);
23990 14146038 clear_xstatecombos((currscr>=128)?1:0);
23991
23992
4/4
✓ Branch 0 taken 34468 times.
✓ Branch 1 taken 14111570 times.
✓ Branch 2 taken 34438 times.
✓ Branch 3 taken 30 times.
14146038 if((hasitem&8) && triggered_screen_secrets)
23993 {
23994 30 int32_t Item=tmpscr->item;
23995
23996
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 24 times.
30 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
23997 {
23998
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
48 items.add(new item((zfix)tmpscr->itemx,
23999
6/12
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 24 times.
✗ Branch 11 not taken.
24 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
24000
6/10
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
24 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
24001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
24002 24 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
24003 24 }
24004
24005 30 hasitem &= ~8;
24006 30 }
24007 14146038 }
24008
24009 //Gets the 4 comboposes indicated by the coordinates, replacing duplicates with '-1'
24010 13401864 void getPoses(int32_t* poses, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
24011 {
24012 int32_t tmp;
24013 13401864 poses[0] = COMBOPOS(x1,y1);
24014
24015 13401864 tmp = COMBOPOS(x1,y2);
24016
2/2
✓ Branch 0 taken 9710949 times.
✓ Branch 1 taken 3690915 times.
13401864 if(tmp == poses[0])
24017 9710949 poses[1] = -1;
24018 3690915 else poses[1] = tmp;
24019
24020 13401864 tmp = COMBOPOS(x2,y1);
24021
3/4
✓ Branch 0 taken 6484562 times.
✓ Branch 1 taken 6917302 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6484562 times.
13401864 if(tmp == poses[0] || tmp == poses[1])
24022 6917302 poses[2] = -1;
24023 6484562 else poses[2] = tmp;
24024
24025 13401864 tmp = COMBOPOS(x2,y2);
24026
6/6
✓ Branch 0 taken 8424280 times.
✓ Branch 1 taken 4977584 times.
✓ Branch 2 taken 6484562 times.
✓ Branch 3 taken 1939718 times.
✓ Branch 4 taken 4733365 times.
✓ Branch 5 taken 1751197 times.
13401864 if(tmp == poses[0] || tmp == poses[1] || tmp == poses[2])
24027 11650667 poses[3] = -1;
24028 1751197 else poses[3] = tmp;
24029 13401864 }
24030
24031 14108144 void HeroClass::checkspecial2(int32_t *ls)
24032 {
24033
6/8
✓ Branch 0 taken 9971231 times.
✓ Branch 1 taken 4136913 times.
✓ Branch 2 taken 9715297 times.
✓ Branch 3 taken 255934 times.
✓ Branch 4 taken 9715297 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9715297 times.
14108144 if(get_qr(qr_OLDSTYLEWARP) && !(diagonalMovement||NO_GRIDLOCK))
24034 {
24035 // Must run fairycircle stuff if currently active, otherwise hero gets stuck!
24036
2/2
✓ Branch 0 taken 21923 times.
✓ Branch 1 taken 9693374 times.
9715297 if (!fairyclk)
24037 {
24038
2/2
✓ Branch 0 taken 2921437 times.
✓ Branch 1 taken 6771937 times.
9693374 if(y.getInt()&7)
24039 2921437 return;
24040
24041
2/2
✓ Branch 0 taken 2954024 times.
✓ Branch 1 taken 3817913 times.
6771937 if(x.getInt()&7)
24042 3817913 return;
24043 2954024 }
24044 2975947 }
24045
24046
2/2
✓ Branch 0 taken 5800 times.
✓ Branch 1 taken 7362994 times.
7368794 if(toogam) return;
24047
24048 7362994 bool didstrig = false;
24049
24050
2/2
✓ Branch 0 taken 14707190 times.
✓ Branch 1 taken 7362954 times.
22070144 for(int32_t i=bigHitbox?0:8; i<16; i+=bigHitbox?15:7)
24051 {
24052
4/4
✓ Branch 0 taken 29414351 times.
✓ Branch 1 taken 14707150 times.
✓ Branch 2 taken 58828662 times.
✓ Branch 3 taken 29414311 times.
102950123 for(int32_t j=0; j<16; j+=15) for(int32_t k=0; k<2; k++)
24053 {
24054
2/2
✓ Branch 0 taken 29414311 times.
✓ Branch 1 taken 29414351 times.
58828662 newcombo const& cmb = combobuf[k>0 ? MAPFFCOMBO(x+j,y+i) : MAPCOMBO(x+j,y+i)];
24055 58828662 int32_t stype = cmb.type;
24056 58828662 int32_t warpsound = cmb.attribytes[0];
24057
2/2
✓ Branch 0 taken 58828460 times.
✓ Branch 1 taken 202 times.
58828662 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
24058 202 stype = cNONE;
24059
2/2
✓ Branch 0 taken 58828628 times.
✓ Branch 1 taken 34 times.
58828662 if(stype==cSWARPA)
24060 {
24061
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1 times.
34 if(tmpscr->flags5&fDIRECTSWARP)
24062 {
24063 1 didpit=true;
24064 1 pitx=x;
24065 1 pity=y;
24066 1 }
24067
24068 34 sdir=dir;
24069 34 dowarp(0,0,warpsound);
24070 34 return;
24071 }
24072
24073
2/2
✓ Branch 0 taken 58828623 times.
✓ Branch 1 taken 5 times.
58828628 if(stype==cSWARPB)
24074 {
24075
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tmpscr->flags5&fDIRECTSWARP)
24076 {
24077 didpit=true;
24078 pitx=x;
24079 pity=y;
24080 }
24081
24082 5 sdir=dir;
24083 5 dowarp(0,1,warpsound);
24084 5 return;
24085 }
24086
24087
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 58828622 times.
58828623 if(stype==cSWARPC)
24088 {
24089
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags5&fDIRECTSWARP)
24090 {
24091 didpit=true;
24092 pitx=x;
24093 pity=y;
24094 }
24095
24096 1 sdir=dir;
24097 1 dowarp(0,2,warpsound);
24098 1 return;
24099 }
24100
24101
1/2
✓ Branch 0 taken 58828622 times.
✗ Branch 1 not taken.
58828622 if(stype==cSWARPD)
24102 {
24103 if(tmpscr->flags5&fDIRECTSWARP)
24104 {
24105 didpit=true;
24106 pitx=x;
24107 pity=y;
24108 }
24109
24110 sdir=dir;
24111 dowarp(0,3,warpsound);
24112 return;
24113 }
24114
24115
1/2
✓ Branch 0 taken 58828622 times.
✗ Branch 1 not taken.
58828622 if(stype==cSWARPR)
24116 {
24117 if(tmpscr->flags5&fDIRECTSWARP)
24118 {
24119 didpit=true;
24120 pitx=x;
24121 pity=y;
24122 }
24123
24124 sdir=dir;
24125 dowarp(0,(zc_oldrand()%4),warpsound);
24126 return;
24127 }
24128
24129 58828622 int32_t pos = COMBOPOS(x+j, y+i);
24130
4/4
✓ Branch 0 taken 58824472 times.
✓ Branch 1 taken 4150 times.
✓ Branch 2 taken 58826143 times.
✓ Branch 3 taken 2479 times.
58828622 if((stype==cSTRIGNOFLAG || stype==cSTRIGFLAG) && stepsecret!=pos)
24131 {
24132
3/4
✓ Branch 0 taken 895 times.
✓ Branch 1 taken 1584 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 895 times.
2479 if(stype==cSTRIGFLAG && canPermSecret())
24133 {
24134
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 603 times.
895 if(!didstrig)
24135 {
24136 603 stepsecret = pos;
24137
24138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 603 times.
603 if(!(tmpscr->flags5&fTEMPSECRETS))
24139 {
24140 603 setmapflag(mSECRET);
24141 603 }
24142 603 sfx(warpsound,pan((int32_t)x));
24143 603 hidden_entrance(0,true,false);
24144 603 didstrig = true;
24145 603 }
24146 895 }
24147 else
24148 {
24149
2/2
✓ Branch 0 taken 680 times.
✓ Branch 1 taken 904 times.
1584 if(!didstrig)
24150 {
24151 904 stepsecret = pos;
24152 904 bool only16_31 = get_qr(qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
24153 904 hidden_entrance(0,true,only16_31);
24154 904 didstrig = true;
24155 //play trigger sound
24156 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
24157 //zprint("Step Secrets SFX: %d\n", thesfx);
24158 //sfx(thesfx,pan((int32_t)x));
24159 904 sfx(warpsound,pan((int32_t)x));
24160 904 }
24161 }
24162 2479 }
24163 88242933 }
24164 14707150 }
24165
24166 7362954 bool RaftPass = false;//Special case for the raft, where only the raft stuff gets checked and nothing else.
24167
24168 // check if he's standing on a warp he just came out of
24169 // But if the QR is checked, it uses the old logic, cause some quests like Ballad of a Bloodline warp you onto a trigger and this new logic bricks that.
24170
2/2
✓ Branch 0 taken 2008546 times.
✓ Branch 1 taken 5354408 times.
7362954 if (!get_qr(qr_210_WARPRETURN))
24171 {
24172
6/6
✓ Branch 0 taken 5343064 times.
✓ Branch 1 taken 11344 times.
✓ Branch 2 taken 349808 times.
✓ Branch 3 taken 4993256 times.
✓ Branch 4 taken 54041 times.
✓ Branch 5 taken 295767 times.
5354408 if(((int32_t)y>=warpy-8&&(int32_t)y<=warpy+7)&&warpy!=-1)
24173 {
24174
5/6
✓ Branch 0 taken 294702 times.
✓ Branch 1 taken 1065 times.
✓ Branch 2 taken 293212 times.
✓ Branch 3 taken 1490 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 293212 times.
295767 if(((int32_t)x>=warpx-8&&(int32_t)x<=warpx+7)&&warpx!=-1)
24175 {
24176
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 293207 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
293212 if (get_qr(qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
24177 293212 else return;
24178 }
24179 2555 }
24180 5061196 }
24181 else
24182 {
24183
2/2
✓ Branch 0 taken 1677138 times.
✓ Branch 1 taken 331408 times.
2008546 if((int(y)&0xF8)==warpy)
24184 {
24185
2/2
✓ Branch 0 taken 4076 times.
✓ Branch 1 taken 327332 times.
331408 if(x==warpx)
24186 {
24187
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 327332 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327332 if (get_qr(qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
24188 327332 else return;
24189 }
24190 4076 }
24191 }
24192
2/2
✓ Branch 0 taken 9382 times.
✓ Branch 1 taken 6733028 times.
6742410 if (!RaftPass) warpy=-1;
24193
24194
6/6
✓ Branch 0 taken 6725647 times.
✓ Branch 1 taken 13219 times.
✓ Branch 2 taken 323798 times.
✓ Branch 3 taken 6401849 times.
✓ Branch 4 taken 244904 times.
✓ Branch 5 taken 78894 times.
6742410 if(((int32_t)y<raftwarpy-(get_qr(qr_BETTER_RAFT_2)?12:8)||(int32_t)y>raftwarpy+(get_qr(qr_BETTER_RAFT_2)?3:7))||raftwarpy==-1)
24195 {
24196 6493962 raftwarpy = -1;
24197 6493962 }
24198
6/6
✓ Branch 0 taken 6726987 times.
✓ Branch 1 taken 11879 times.
✓ Branch 2 taken 311861 times.
✓ Branch 3 taken 6415126 times.
✓ Branch 4 taken 226483 times.
✓ Branch 5 taken 85378 times.
6738866 if (((int32_t)x<raftwarpx - 8 || (int32_t)x>raftwarpx + 7) || raftwarpx == -1)
24199 {
24200 6512383 raftwarpx = -1;
24201 6512383 }
24202 6720798 int32_t tx=x;
24203 6720798 int32_t ty=y;
24204
24205 6720798 int32_t flag=0;
24206 6720798 int32_t flag2=0;
24207 6720798 int32_t flag3=0;
24208 6720798 int32_t type=0;
24209 6720798 int32_t water=0;
24210 6720798 int32_t index = 0;
24211
24212 6720798 bool setsave=false;
24213 6720798 int32_t warpsfx2 = 0;
24214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6720798 times.
6720798 if (RaftPass) goto RaftingStuff;
24215
24216 //bool gotpit=false;
24217
24218 int32_t x1,x2,y1,y2;
24219 6720798 x1 = tx;
24220 6720798 x2 = tx+15;
24221 6720798 y1 = ty;
24222 6720798 y2 = ty+15;
24223
24224
5/6
✓ Branch 0 taken 2513710 times.
✓ Branch 1 taken 4207088 times.
✓ Branch 2 taken 2513710 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12230 times.
✓ Branch 5 taken 2525940 times.
6720798 if((diagonalMovement||NO_GRIDLOCK))
24225 {
24226 4219318 x1 = tx+4;
24227 4219318 x2 = tx+11;
24228 4219318 y1 = ty+4;
24229 4219318 y2 = ty+11;
24230 4219318 }
24231
24232 int32_t types[4];
24233 6745258 types[0]=types[1]=types[2]=types[3]=-1;
24234 int32_t cids[4];
24235 int32_t ffcids[4];
24236 6745258 cids[0]=cids[1]=cids[2]=cids[3]=-1;
24237 6745258 ffcids[0]=ffcids[1]=ffcids[2]=ffcids[3]=-1;
24238 //
24239 // First, let's find flag1 (combo flag), flag2 (inherent flag) and flag3 (FFC flag)...
24240 //
24241 6745258 types[0] = MAPFLAG(x1,y1);
24242 6745258 types[1] = MAPFLAG(x1,y2);
24243 6745258 types[2] = MAPFLAG(x2,y1);
24244 6745258 types[3] = MAPFLAG(x2,y2);
24245
24246
24247 //MAPFFCOMBO
24248
24249
24250
6/6
✓ Branch 0 taken 6514080 times.
✓ Branch 1 taken 231178 times.
✓ Branch 2 taken 6486895 times.
✓ Branch 3 taken 27185 times.
✓ Branch 4 taken 81428 times.
✓ Branch 5 taken 6405467 times.
6745258 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
24251 6405467 flag = types[0];
24252 // 2.10 compatibility...
24253
10/10
✓ Branch 0 taken 147946 times.
✓ Branch 1 taken 191845 times.
✓ Branch 2 taken 121855 times.
✓ Branch 3 taken 26091 times.
✓ Branch 4 taken 107990 times.
✓ Branch 5 taken 13865 times.
✓ Branch 6 taken 107894 times.
✓ Branch 7 taken 96 times.
✓ Branch 8 taken 98 times.
✓ Branch 9 taken 107796 times.
339791 else if(y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
24254 14059 flag = types[0];
24255
24256
24257 6745258 types[0] = MAPCOMBOFLAG(x1,y1);
24258 6745258 types[1] = MAPCOMBOFLAG(x1,y2);
24259 6745258 types[2] = MAPCOMBOFLAG(x2,y1);
24260 6745258 types[3] = MAPCOMBOFLAG(x2,y2);
24261
24262
6/6
✓ Branch 0 taken 6672469 times.
✓ Branch 1 taken 72789 times.
✓ Branch 2 taken 6665455 times.
✓ Branch 3 taken 7014 times.
✓ Branch 4 taken 17736 times.
✓ Branch 5 taken 6647719 times.
6745258 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
24263 6647719 flag2 = types[0];
24264
9/12
✓ Branch 0 taken 20949 times.
✓ Branch 1 taken 76590 times.
✓ Branch 2 taken 3350 times.
✓ Branch 3 taken 17599 times.
✓ Branch 4 taken 2740 times.
✓ Branch 5 taken 610 times.
✓ Branch 6 taken 2740 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2740 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2740 times.
97539 else if(!get_qr(qr_FAIRY_FLAG_COMPAT) && y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
24265 flag2 = types[0];
24266
24267 6745258 types[0] = MAPFFCOMBOFLAG(x1,y1);
24268 6745258 types[1] = MAPFFCOMBOFLAG(x1,y2);
24269 6745258 types[2] = MAPFFCOMBOFLAG(x2,y1);
24270 6745258 types[3] = MAPFFCOMBOFLAG(x2,y2);
24271
24272
24273 //
24274
24275
6/6
✓ Branch 0 taken 6732425 times.
✓ Branch 1 taken 12833 times.
✓ Branch 2 taken 6732278 times.
✓ Branch 3 taken 147 times.
✓ Branch 4 taken 17 times.
✓ Branch 5 taken 6732261 times.
6745258 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
24276 6732261 flag3 = types[0];
24277
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 12997 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
12997 else if(!get_qr(qr_FAIRY_FLAG_COMPAT) && y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
24278 flag3 = types[0];
24279
24280 //
24281 // Now, let's check for warp combos...
24282 //
24283
24284 //
24285
24286 6745258 cids[0] = MAPCOMBO(x1,y1);
24287 6745258 cids[1] = MAPCOMBO(x1,y2);
24288 6745258 cids[2] = MAPCOMBO(x2,y1);
24289 6745258 cids[3] = MAPCOMBO(x2,y2);
24290
24291 6745258 types[0] = COMBOTYPE(x1,y1);
24292
24293
2/2
✓ Branch 0 taken 171667 times.
✓ Branch 1 taken 6553905 times.
6745258 if(MAPFFCOMBO(x1,y1))
24294 {
24295 171667 types[0] = FFCOMBOTYPE(x1,y1);
24296 171667 cids[0] = MAPFFCOMBO(x1,y1);
24297 171667 }
24298
24299 6725572 types[1] = COMBOTYPE(x1,y2);
24300
24301
2/2
✓ Branch 0 taken 127067 times.
✓ Branch 1 taken 6598505 times.
6725572 if(MAPFFCOMBO(x1,y2))
24302 {
24303 127067 types[1] = FFCOMBOTYPE(x1,y2);
24304 127067 cids[1] = MAPFFCOMBO(x1,y2);
24305 127067 }
24306
24307 6725572 types[2] = COMBOTYPE(x2,y1);
24308
24309
2/2
✓ Branch 0 taken 170956 times.
✓ Branch 1 taken 6554616 times.
6725572 if(MAPFFCOMBO(x2,y1))
24310 {
24311 170956 types[2] = FFCOMBOTYPE(x2,y1);
24312 170956 cids[2] = MAPFFCOMBO(x2,y1);
24313 170956 }
24314 6725572 types[3] = COMBOTYPE(x2,y2);
24315
24316
2/2
✓ Branch 0 taken 127545 times.
✓ Branch 1 taken 6598027 times.
6725572 if(MAPFFCOMBO(x2,y2))
24317 {
24318 127545 types[3] = FFCOMBOTYPE(x2,y2);
24319 127545 cids[3] = MAPFFCOMBO(x2,y2);
24320 127545 }
24321 // Change B, C and D warps into A, for the comparison below...
24322
2/2
✓ Branch 0 taken 26932112 times.
✓ Branch 1 taken 6725572 times.
33657684 for(int32_t i=0; i<4; i++)
24323 {
24324
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 26931788 times.
26932112 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
24325 {
24326 324 types[i] = cNONE;
24327 324 continue;
24328 }
24329
2/2
✓ Branch 0 taken 6925 times.
✓ Branch 1 taken 26924863 times.
26931788 if(types[i]==cCAVE)
24330 {
24331 6925 index=0;
24332 6925 warpsfx2 = combobuf[cids[i]].attribytes[0];
24333 6925 }
24334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26924863 times.
26924863 else if(types[i]==cCAVEB)
24335 {
24336 types[i]=cCAVE;
24337 index=1;
24338 warpsfx2 = combobuf[cids[i]].attribytes[0];
24339 }
24340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26924863 times.
26924863 else if(types[i]==cCAVEC)
24341 {
24342 types[i]=cCAVE;
24343 index=2;
24344 warpsfx2 = combobuf[cids[i]].attribytes[0];
24345 }
24346
1/2
✓ Branch 0 taken 26924863 times.
✗ Branch 1 not taken.
26924863 else if(types[i]==cCAVED)
24347 {
24348 types[i]=cCAVE;
24349 index=3;
24350 warpsfx2 = combobuf[cids[i]].attribytes[0];
24351 }
24352
24353
2/2
✓ Branch 0 taken 9519 times.
✓ Branch 1 taken 26922269 times.
26931788 if(types[i]==cPIT)
24354 {
24355 9519 index=0;
24356 9519 warpsfx2 = combobuf[cids[i]].attribytes[0];
24357 9519 }
24358
2/2
✓ Branch 0 taken 5708 times.
✓ Branch 1 taken 26916561 times.
26922269 else if(types[i]==cPITB)
24359 {
24360 5708 types[i]=cPIT;
24361 5708 warpsfx2 = combobuf[cids[i]].attribytes[0];
24362 5708 index=1;
24363 5708 }
24364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26916561 times.
26916561 else if(types[i]==cPITC)
24365 {
24366 types[i]=cPIT;
24367 warpsfx2 = combobuf[cids[i]].attribytes[0];
24368 index=2;
24369 }
24370
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 26916555 times.
26916561 else if(types[i]==cPITD)
24371 {
24372 6 types[i]=cPIT;
24373 6 warpsfx2 = combobuf[cids[i]].attribytes[0];
24374 6 index=3;
24375 6 }
24376
1/2
✓ Branch 0 taken 26916555 times.
✗ Branch 1 not taken.
26916555 else if(types[i]==cPITR)
24377 {
24378 types[i]=cPIT;
24379 warpsfx2 = combobuf[cids[i]].attribytes[0];
24380 index=zc_oldrand()%4;
24381 }
24382
24383
2/2
✓ Branch 0 taken 32793 times.
✓ Branch 1 taken 26898995 times.
26931788 if(types[i]==cSTAIR)
24384 {
24385 32793 index=0;
24386 32793 warpsfx2 = combobuf[cids[i]].attribytes[0];
24387 32793 }
24388
2/2
✓ Branch 0 taken 1697 times.
✓ Branch 1 taken 26897298 times.
26898995 else if(types[i]==cSTAIRB)
24389 {
24390 1697 types[i]=cSTAIR;
24391 1697 warpsfx2 = combobuf[cids[i]].attribytes[0];
24392 1697 index=1;
24393 1697 }
24394
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 26897180 times.
26897298 else if(types[i]==cSTAIRC)
24395 {
24396 118 types[i]=cSTAIR;
24397 118 warpsfx2 = combobuf[cids[i]].attribytes[0];
24398 118 index=2;
24399 118 }
24400
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 26896977 times.
26897180 else if(types[i]==cSTAIRD)
24401 {
24402 203 types[i]=cSTAIR;
24403 203 warpsfx2 = combobuf[cids[i]].attribytes[0];
24404 203 index=3;
24405 203 }
24406
1/2
✓ Branch 0 taken 26896977 times.
✗ Branch 1 not taken.
26896977 else if(types[i]==cSTAIRR)
24407 {
24408 types[i]=cSTAIR;
24409 index=zc_oldrand()%4;
24410 warpsfx2 = combobuf[cids[i]].attribytes[0];
24411 }
24412
24413
2/2
✓ Branch 0 taken 6563 times.
✓ Branch 1 taken 26925225 times.
26931788 if(types[i]==cCAVE2)
24414 {
24415 6563 index=0;
24416 6563 warpsfx2 = combobuf[cids[i]].attribytes[0];
24417 6563 }
24418
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 26924892 times.
26925225 else if(types[i]==cCAVE2B)
24419 {
24420 333 types[i]=cCAVE2;
24421 333 index=1;
24422 333 warpsfx2 = combobuf[cids[i]].attribytes[0];
24423 333 }
24424
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 26924729 times.
26924892 else if(types[i]==cCAVE2C)
24425 {
24426 163 types[i]=cCAVE2;
24427 163 warpsfx2 = combobuf[cids[i]].attribytes[0];
24428 163 index=2;
24429 163 }
24430
1/2
✓ Branch 0 taken 26924729 times.
✗ Branch 1 not taken.
26924729 else if(types[i]==cCAVE2D)
24431 {
24432 types[i]=cCAVE2;
24433 warpsfx2 = combobuf[cids[i]].attribytes[0];
24434 index=3;
24435 }
24436
24437
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 26931633 times.
26931788 if(types[i]==cSWIMWARP)
24438 {
24439 155 index=0;
24440 155 warpsfx2 = combobuf[cids[i]].attribytes[0];
24441 155 }
24442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26931633 times.
26931633 else if(types[i]==cSWIMWARPB)
24443 {
24444 types[i]=cSWIMWARP;
24445 warpsfx2 = combobuf[cids[i]].attribytes[0];
24446 index=1;
24447 }
24448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26931633 times.
26931633 else if(types[i]==cSWIMWARPC)
24449 {
24450 types[i]=cSWIMWARP;
24451 warpsfx2 = combobuf[cids[i]].attribytes[0];
24452 index=2;
24453 }
24454
1/2
✓ Branch 0 taken 26931633 times.
✗ Branch 1 not taken.
26931633 else if(types[i]==cSWIMWARPD)
24455 {
24456 types[i]=cSWIMWARP;
24457 warpsfx2 = combobuf[cids[i]].attribytes[0];
24458 index=3;
24459 }
24460
24461
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 26931193 times.
26931788 if(types[i]==cDIVEWARP)
24462 {
24463 595 index=0;
24464 595 warpsfx2 = combobuf[cids[i]].attribytes[0];
24465 595 }
24466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26931193 times.
26931193 else if(types[i]==cDIVEWARPB)
24467 {
24468 types[i]=cDIVEWARP;
24469 warpsfx2 = combobuf[cids[i]].attribytes[0];
24470 index=1;
24471 }
24472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26931193 times.
26931193 else if(types[i]==cDIVEWARPC)
24473 {
24474 types[i]=cDIVEWARP;
24475 warpsfx2 = combobuf[cids[i]].attribytes[0];
24476 index=2;
24477 }
24478
1/2
✓ Branch 0 taken 26931193 times.
✗ Branch 1 not taken.
26931193 else if(types[i]==cDIVEWARPD)
24479 {
24480 types[i]=cDIVEWARP;
24481 warpsfx2 = combobuf[cids[i]].attribytes[0];
24482 index=3;
24483 }
24484
24485
2/2
✓ Branch 0 taken 8272 times.
✓ Branch 1 taken 26923516 times.
26931788 if(types[i]==cSTEP) warpsfx2 = combobuf[cids[i]].attribytes[0];
24486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26923516 times.
26923516 else if(types[i]==cSTEPSAME) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0];}
24487
2/2
✓ Branch 0 taken 26923372 times.
✓ Branch 1 taken 144 times.
26923516 else if(types[i]==cSTEPALL) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0]; }
24488 26931788 }
24489
24490 // Special case for step combos; otherwise, they act oddly in some cases
24491
8/8
✓ Branch 0 taken 6147505 times.
✓ Branch 1 taken 578067 times.
✓ Branch 2 taken 6083954 times.
✓ Branch 3 taken 63551 times.
✓ Branch 4 taken 1452 times.
✓ Branch 5 taken 640166 times.
✓ Branch 6 taken 128237 times.
✓ Branch 7 taken 126785 times.
6725572 if((types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])||(types[1]==cSTEP&&types[3]==cSTEP))
24492 {
24493
7/8
✓ Branch 0 taken 5925920 times.
✓ Branch 1 taken 29797 times.
✓ Branch 2 taken 5925920 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1549 times.
✓ Branch 5 taken 5924371 times.
✓ Branch 6 taken 420 times.
✓ Branch 7 taken 1129 times.
6212191 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_qr(qr_MSGFREEZE)))
24494 5925500 type = types[1];
24495 5955717 }
24496
24497 //Generic Step
24498
7/8
✓ Branch 0 taken 6700498 times.
✓ Branch 1 taken 22170 times.
✓ Branch 2 taken 6700498 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1890 times.
✓ Branch 5 taken 6698608 times.
✓ Branch 6 taken 756 times.
✓ Branch 7 taken 1134 times.
6722668 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_qr(qr_MSGFREEZE)))
24499 {
24500 int32_t poses[4];
24501 int32_t sensPoses[4];
24502 6699742 int32_t xPoses[4] = {tx + 4, tx + 11, tx, tx + 15};
24503 6699742 int32_t yPoses[4] = {ty + 4, ty + 11, ty+(bigHitbox?0:8), ty + 15};
24504
4/6
✓ Branch 0 taken 2491073 times.
✓ Branch 1 taken 4208669 times.
✓ Branch 2 taken 2491073 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2491073 times.
6699742 if(diagonalMovement||NO_GRIDLOCK)
24505 4208669 getPoses(poses, tx+4, ty+4, tx+11, ty+11);
24506 2491073 else getPoses(poses, tx, ty, tx+15, ty+15);
24507 6699742 getPoses(sensPoses, tx, ty+(bigHitbox?0:8), tx+15, ty+15);
24508 6699742 bool hasStep[4] = {false};
24509
2/2
✓ Branch 0 taken 26798968 times.
✓ Branch 1 taken 6699742 times.
33498710 for(auto p = 0; p < 4; ++p)
24510 {
24511
2/2
✓ Branch 0 taken 26784324 times.
✓ Branch 1 taken 187504912 times.
214289236 for(auto lyr = 0; lyr < 7; ++lyr)
24512 {
24513
2/2
✓ Branch 0 taken 87750110 times.
✓ Branch 1 taken 99754802 times.
187504912 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
24514
4/4
✓ Branch 0 taken 87750110 times.
✓ Branch 1 taken 99754802 times.
✓ Branch 2 taken 14644 times.
✓ Branch 3 taken 187490268 times.
187504912 if((cmb && (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS)))
24515 187504912 || types[p] == cSTEP)
24516 {
24517 14644 hasStep[p] = true;
24518 14644 break;
24519 }
24520 187490268 }
24521 26798968 }
24522 6699742 bool canNormalStep = true;
24523
2/2
✓ Branch 0 taken 2348 times.
✓ Branch 1 taken 6712315 times.
6714663 for(auto p = 0; p < 4; ++p)
24524 {
24525
2/2
✓ Branch 0 taken 6706243 times.
✓ Branch 1 taken 6072 times.
6712315 if(poses[p] < 0) continue;
24526
2/2
✓ Branch 0 taken 8849 times.
✓ Branch 1 taken 6697394 times.
6706243 if(!hasStep[p])
24527 {
24528 6697394 canNormalStep = false;
24529 6697394 break;
24530 }
24531 8849 }
24532
2/2
✓ Branch 0 taken 26798968 times.
✓ Branch 1 taken 6699742 times.
33498710 for(auto p = 0; p < 4; ++p)
24533 {
24534
2/2
✓ Branch 0 taken 187592776 times.
✓ Branch 1 taken 26798968 times.
214391744 for(auto lyr = 0; lyr < 7; ++lyr)
24535 {
24536
2/2
✓ Branch 0 taken 87823442 times.
✓ Branch 1 taken 99769334 times.
187592776 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
24537
2/2
✓ Branch 0 taken 89442731 times.
✓ Branch 1 taken 98150045 times.
187592776 newcombo const* cmb2 = sensPoses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[sensPoses[p]]];
24538
6/6
✓ Branch 0 taken 65744 times.
✓ Branch 1 taken 187527032 times.
✓ Branch 2 taken 27405 times.
✓ Branch 3 taken 38339 times.
✓ Branch 4 taken 27287 times.
✓ Branch 5 taken 118 times.
187592776 if(canNormalStep && cmb && (cmb->triggerflags[0] & combotriggerSTEP))
24539 {
24540 118 do_trigger_combo(lyr,poses[p]);
24541
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 59 times.
118 if(poses[p] == sensPoses[p]) continue;
24542 59 }
24543
4/4
✓ Branch 0 taken 89442672 times.
✓ Branch 1 taken 98150045 times.
✓ Branch 2 taken 89436162 times.
✓ Branch 3 taken 6510 times.
187592717 if(cmb2 && (cmb2->triggerflags[0] & combotriggerSTEPSENS))
24544 {
24545 6510 do_trigger_combo(lyr,sensPoses[p]);
24546 6510 }
24547 187592717 }
24548 26798968 }
24549 6699742 word c = tmpscr->numFFC();
24550
2/2
✓ Branch 0 taken 186731216 times.
✓ Branch 1 taken 6699742 times.
193430958 for(word i=0; i<c; i++)
24551 {
24552 186731216 bool found = false;
24553
2/2
✓ Branch 0 taken 373462432 times.
✓ Branch 1 taken 186731216 times.
560193648 for(auto xch = 0; xch < 2; ++xch)
24554 {
24555
2/2
✓ Branch 0 taken 746924864 times.
✓ Branch 1 taken 373462432 times.
1120387296 for(auto ych = 0; ych < 2; ++ych)
24556 {
24557
2/2
✓ Branch 0 taken 746321675 times.
✓ Branch 1 taken 603189 times.
746924864 if (ffcIsAt(i, xPoses[xch], yPoses[ych]))
24558 {
24559 603189 found = true;
24560 603189 }
24561 746924864 }
24562 373462432 }
24563
2/2
✓ Branch 0 taken 186509572 times.
✓ Branch 1 taken 221644 times.
186731216 if (found)
24564 {
24565 221644 ffcdata& ffc = tmpscr->ffcs[i];
24566 221644 newcombo const* cmb = &combobuf[ffc.data];
24567
2/2
✓ Branch 0 taken 221642 times.
✓ Branch 1 taken 2 times.
221644 if (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS))
24568 {
24569 2 do_trigger_combo_ffc(i);
24570 2 }
24571 221644 }
24572 186731216 }
24573 6699742 }
24574
2/2
✓ Branch 0 taken 6720288 times.
✓ Branch 1 taken 2380 times.
6722668 if(isDiving()) //Dive-> triggerflag
24575 {
24576 2380 int pos = COMBOPOS(x+8,y+8);
24577 2380 int x1=x,x2=x+15,y1=y+(bigHitbox?0:8),y2=y+15;
24578 2380 int xposes[] = {x1,x1,x2,x2};
24579 2380 int yposes[] = {y1,y2,y1,y2};
24580 int32_t poses[4];
24581 2380 getPoses(poses,x1,y1,x2,y2);
24582
2/2
✓ Branch 0 taken 16660 times.
✓ Branch 1 taken 2380 times.
19040 for(auto lyr = 0; lyr < 7; ++lyr)
24583 {
24584 16660 mapscr* s = FFCore.tempScreens[lyr];
24585 16660 newcombo const& cmb = combobuf[s->data[pos]];
24586 16660 bool didtrig = false;
24587
1/2
✓ Branch 0 taken 16660 times.
✗ Branch 1 not taken.
16660 if (cmb.triggerflags[3] & combotriggerDIVETRIG)
24588 {
24589 do_trigger_combo(lyr,pos);
24590 didtrig = true;
24591 }
24592
2/2
✓ Branch 0 taken 66640 times.
✓ Branch 1 taken 16660 times.
83300 for(auto q = 0; q < 4; ++q)
24593 {
24594
2/2
✓ Branch 0 taken 33593 times.
✓ Branch 1 taken 33047 times.
66640 if(poses[q] < 0) continue;
24595
3/4
✓ Branch 0 taken 16660 times.
✓ Branch 1 taken 16933 times.
✓ Branch 2 taken 16660 times.
✗ Branch 3 not taken.
33593 if(poses[q] == pos && didtrig) continue;
24596 33593 newcombo const& cmb = combobuf[s->data[poses[q]]];
24597
1/2
✓ Branch 0 taken 33593 times.
✗ Branch 1 not taken.
33593 if (cmb.triggerflags[3] & combotriggerDIVESENSTRIG)
24598 do_trigger_combo(lyr,poses[q]);
24599 33593 }
24600 16660 }
24601 2380 word c = tmpscr->numFFC();
24602
2/2
✓ Branch 0 taken 66544 times.
✓ Branch 1 taken 2380 times.
68924 for(word i=0; i<c; i++)
24603 {
24604 66544 ffcdata& ffc = tmpscr->ffcs[i];
24605 66544 newcombo const& cmb = combobuf[ffc.data];
24606
2/4
✓ Branch 0 taken 66544 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66544 times.
66544 if ((cmb.triggerflags[3] & combotriggerDIVETRIG) && ffcIsAt(i, x+8, y+8))
24607 {
24608 do_trigger_combo_ffc(i);
24609 }
24610
1/2
✓ Branch 0 taken 66544 times.
✗ Branch 1 not taken.
66544 else if(cmb.triggerflags[3] & combotriggerDIVESENSTRIG)
24611 {
24612 for(auto q = 0; q < 4; ++q)
24613 {
24614 if(ffcIsAt(i, xposes[q], yposes[q]))
24615 {
24616 do_trigger_combo_ffc(i);
24617 break;
24618 }
24619 }
24620 }
24621 66544 }
24622 2380 }
24623
24624 //
24625 // Now, let's check for Save combos...
24626 //
24627 6722668 x1 = tx+4;
24628 6722668 x2 = tx+11;
24629 6722668 y1 = ty+4;
24630 6722668 y2 = ty+11;
24631
24632 6722668 types[0] = COMBOTYPE(x1,y1);
24633 6722668 cids[0] = MAPCOMBO(x1,y1);
24634
24635
2/2
✓ Branch 0 taken 171644 times.
✓ Branch 1 taken 6551024 times.
6722668 if(MAPFFCOMBO(x1,y1))
24636 {
24637 171644 types[0] = FFCOMBOTYPE(x1,y1);
24638 171644 cids[0] = MAPFFCOMBO(x1,y1);
24639 171644 }
24640
24641 6722668 types[1] = COMBOTYPE(x1,y2);
24642 6722668 cids[1] = MAPCOMBO(x1,y2);
24643
24644
2/2
✓ Branch 0 taken 127081 times.
✓ Branch 1 taken 6595587 times.
6722668 if(MAPFFCOMBO(x1,y2))
24645 {
24646 127081 types[1] = FFCOMBOTYPE(x1,y2);
24647 127081 cids[1] = MAPFFCOMBO(x1,y2);
24648 127081 }
24649
24650 6722668 types[2] = COMBOTYPE(x2,y1);
24651 6722668 cids[2] = MAPCOMBO(x2,y1);
24652
24653
2/2
✓ Branch 0 taken 170941 times.
✓ Branch 1 taken 6551727 times.
6722668 if(MAPFFCOMBO(x2,y1))
24654 {
24655 170941 types[2] = FFCOMBOTYPE(x2,y1);
24656 170941 cids[2] = MAPFFCOMBO(x2,y1);
24657 170941 }
24658
24659 6722668 types[3] = COMBOTYPE(x2,y2);
24660 6722668 cids[3] = MAPCOMBO(x2,y2);
24661
24662
2/2
✓ Branch 0 taken 127560 times.
✓ Branch 1 taken 6595108 times.
6722668 if(MAPFFCOMBO(x2,y2))
24663 {
24664 127560 types[3] = FFCOMBOTYPE(x2,y2);
24665 127560 cids[3] = MAPFFCOMBO(x2,y2);
24666 127560 }
24667
24668
24669
2/2
✓ Branch 0 taken 6722668 times.
✓ Branch 1 taken 26932112 times.
33654780 for(int32_t i=0; i<4; i++)
24670 {
24671
2/2
✓ Branch 0 taken 26931788 times.
✓ Branch 1 taken 324 times.
26932112 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
24672 {
24673
2/4
✓ Branch 0 taken 324 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 324 times.
324 if(types[i] == cSAVE || types[i] == cSAVE2)
24674 {
24675 types[i] = cNONE;
24676 setsave = false;
24677 break;
24678 }
24679 324 }
24680
2/2
✓ Branch 0 taken 26930826 times.
✓ Branch 1 taken 1286 times.
26932112 if(types[i]==cSAVE) setsave=true;
24681
24682
1/2
✓ Branch 0 taken 26932112 times.
✗ Branch 1 not taken.
26932112 if(types[i]==cSAVE2) setsave=true;
24683 26932112 }
24684
24685
8/8
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 6722237 times.
✓ Branch 2 taken 343 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 335 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 106 times.
✓ Branch 7 taken 229 times.
6722668 if(setsave && types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
24686 {
24687 229 last_savepoint_id = cids[0];
24688 229 type = types[0];
24689 229 }
24690 //
24691 // Now, let's check for Drowning combos...
24692 //
24693
4/4
✓ Branch 0 taken 2617048 times.
✓ Branch 1 taken 4105620 times.
✓ Branch 2 taken 10360 times.
✓ Branch 3 taken 2626072 times.
6722668 if(get_qr(qr_DROWN) || CanSideSwim())
24694 {
24695 4115980 y1 = ty+9;
24696 4115980 y2 = ty+15;
24697
2/2
✓ Branch 0 taken 1043091 times.
✓ Branch 1 taken 3072889 times.
4115980 if (get_qr(qr_SMARTER_WATER))
24698 {
24699
4/4
✓ Branch 0 taken 11287 times.
✓ Branch 1 taken 1031804 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 8892 times.
1052005 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
24700
2/2
✓ Branch 0 taken 10186 times.
✓ Branch 1 taken 1101 times.
11287 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
24701
2/2
✓ Branch 0 taken 8914 times.
✓ Branch 1 taken 1272 times.
10186 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
24702 8914 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
24703 1043091 }
24704 else
24705 {
24706 3072889 types[0] = COMBOTYPE(x1,y1);
24707
24708
2/2
✓ Branch 0 taken 2969390 times.
✓ Branch 1 taken 103499 times.
3072889 if(MAPFFCOMBO(x1,y1))
24709 103499 types[0] = FFCOMBOTYPE(x1,y1);
24710
24711 3072889 types[1] = COMBOTYPE(x1,y2);
24712
24713
2/2
✓ Branch 0 taken 2982872 times.
✓ Branch 1 taken 90017 times.
3072889 if(MAPFFCOMBO(x1,y2))
24714 90017 types[1] = FFCOMBOTYPE(x1,y2);
24715
24716 3072889 types[2] = COMBOTYPE(x2,y1);
24717
24718
2/2
✓ Branch 0 taken 2967696 times.
✓ Branch 1 taken 105193 times.
3072889 if(MAPFFCOMBO(x2,y1))
24719 105193 types[2] = FFCOMBOTYPE(x2,y1);
24720
24721 3072889 types[3] = COMBOTYPE(x2,y2);
24722
24723
2/2
✓ Branch 0 taken 2979440 times.
✓ Branch 1 taken 93449 times.
3072889 if(MAPFFCOMBO(x2,y2))
24724 93449 types[3] = FFCOMBOTYPE(x2,y2);
24725
24726 3072889 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
24727
2/2
✓ Branch 0 taken 2974116 times.
✓ Branch 1 taken 98773 times.
3072889 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
24728 98773 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
24729
24730
5/6
✓ Branch 0 taken 8991 times.
✓ Branch 1 taken 3063898 times.
✓ Branch 2 taken 8624 times.
✓ Branch 3 taken 367 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8166 times.
3081055 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
24731
3/4
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 458 times.
✓ Branch 2 taken 8166 times.
✗ Branch 3 not taken.
8624 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
24732 8166 water = typec;
24733 }
24734 4115980 }
24735
24736
24737 // Pits have a bigger 'hitbox' than stairs...
24738 6742052 x1 = tx+7;
24739 6742052 x2 = tx+8;
24740 6742052 y1 = ty+7+(bigHitbox?0:4);
24741 6742052 y2 = ty+8+(bigHitbox?0:4);
24742
24743 6742052 types[0] = COMBOTYPE(x1,y1);
24744 6742052 cids[0] = MAPCOMBO(x1,y1);
24745
24746
2/2
✓ Branch 0 taken 128120 times.
✓ Branch 1 taken 6613932 times.
6742052 if(MAPFFCOMBO(x1,y1))
24747 {
24748 128120 types[0] = FFCOMBOTYPE(x1,y1);
24749 128120 cids[0] = MAPFFCOMBO(x1,y1);
24750 128120 }
24751
24752 6742052 types[1] = COMBOTYPE(x1,y2);
24753 6742052 cids[1] = MAPCOMBO(x1,y2);
24754
24755
2/2
✓ Branch 0 taken 127071 times.
✓ Branch 1 taken 6614981 times.
6742052 if(MAPFFCOMBO(x1,y2))
24756 {
24757 127071 types[1] = FFCOMBOTYPE(x1,y2);
24758 127071 cids[1] = MAPFFCOMBO(x1,y2);
24759 127071 }
24760 6742052 types[2] = COMBOTYPE(x2,y1);
24761 6742052 cids[2] = MAPCOMBO(x2,y1);
24762
24763
2/2
✓ Branch 0 taken 128786 times.
✓ Branch 1 taken 6613266 times.
6742052 if(MAPFFCOMBO(x2,y1))
24764 {
24765 128786 types[2] = FFCOMBOTYPE(x2,y1);
24766 128786 cids[2] = MAPFFCOMBO(x2,y1);
24767 128786 }
24768
24769 6742052 types[3] = COMBOTYPE(x2,y2);
24770 6742052 cids[3] = MAPCOMBO(x2,y2);
24771
24772
2/2
✓ Branch 0 taken 127767 times.
✓ Branch 1 taken 6614285 times.
6742052 if(MAPFFCOMBO(x2,y2))
24773 {
24774 127767 types[3] = FFCOMBOTYPE(x2,y2);
24775 127767 cids[3] = MAPFFCOMBO(x2,y2);
24776 127767 }
24777
24778
2/2
✓ Branch 0 taken 26932112 times.
✓ Branch 1 taken 6742052 times.
33674164 for(int32_t i=0; i<4; i++)
24779 {
24780
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 26931848 times.
26932112 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
24781 {
24782 264 types[i] = cNONE;
24783 264 continue;
24784 }
24785
2/2
✓ Branch 0 taken 3037 times.
✓ Branch 1 taken 26928811 times.
26931848 if(types[i]==cPIT)
24786 {
24787 3037 index=0;
24788 3037 warpsfx2 = combobuf[cids[i]].attribytes[0];
24789 3037 }
24790
2/2
✓ Branch 0 taken 5004 times.
✓ Branch 1 taken 26923807 times.
26928811 else if(types[i]==cPITB)
24791 {
24792 5004 types[i]=cPIT;
24793 5004 index=1;
24794 5004 warpsfx2 = combobuf[cids[i]].attribytes[0];
24795 5004 }
24796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26923807 times.
26923807 else if(types[i]==cPITC)
24797 {
24798 types[i]=cPIT;
24799 index=2;
24800 warpsfx2 = combobuf[cids[i]].attribytes[0];
24801 }
24802
2/2
✓ Branch 0 taken 26923805 times.
✓ Branch 1 taken 2 times.
26923807 else if(types[i]==cPITD)
24803 {
24804 2 types[i]=cPIT;
24805 2 index=3;
24806 2 warpsfx2 = combobuf[cids[i]].attribytes[0];
24807 2 }
24808 26931848 }
24809
24810
8/8
✓ Branch 0 taken 6731023 times.
✓ Branch 1 taken 11029 times.
✓ Branch 2 taken 6731005 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 6730807 times.
✓ Branch 5 taken 198 times.
✓ Branch 6 taken 10776 times.
✓ Branch 7 taken 6739739 times.
6742052 if(types[0]==cPIT||types[1]==cPIT||types[2]==cPIT||types[3]==cPIT)
24811
3/8
✓ Branch 0 taken 2221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2221 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2221 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
24242 if(action!=freeze&&action!=sideswimfreeze&& (!msg_active || !get_qr(qr_MSGFREEZE)))
24812 2221 type=cPIT;
24813
24814 //
24815 // Time to act on our results for type, flag, flag2 and flag3...
24816 //
24817
3/4
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 6741731 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 229 times.
6741960 if(type==cSAVE&&currscr<128)
24818 229 *ls=1;
24819
24820
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6741960 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6741960 if(type==cSAVE2&&currscr<128)
24821 *ls=2;
24822
24823
8/8
✓ Branch 0 taken 6722678 times.
✓ Branch 1 taken 19282 times.
✓ Branch 2 taken 6706263 times.
✓ Branch 3 taken 16415 times.
✓ Branch 4 taken 6705733 times.
✓ Branch 5 taken 530 times.
✓ Branch 6 taken 13800 times.
✓ Branch 7 taken 6719533 times.
6741960 if(refilling==REFILL_LIFE || flag==mfFAIRY||flag2==mfFAIRY||flag3==mfFAIRY)
24824 {
24825 50027 fairycircle(REFILL_LIFE);
24826
24827
2/2
✓ Branch 0 taken 4332 times.
✓ Branch 1 taken 22963 times.
50027 if(fairyclk!=0) return;
24828 4332 }
24829
24830
7/8
✓ Branch 0 taken 6710051 times.
✓ Branch 1 taken 13814 times.
✓ Branch 2 taken 6709969 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 6709969 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13828 times.
✓ Branch 7 taken 6723797 times.
6723865 if(refilling==REFILL_MAGIC || flag==mfMAGICFAIRY||flag2==mfMAGICFAIRY||flag3==mfMAGICFAIRY)
24831 {
24832 27724 fairycircle(REFILL_MAGIC);
24833
24834
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 1 times.
27724 if(fairyclk!=0) return;
24835 1 }
24836
24837
7/8
✓ Branch 0 taken 6709936 times.
✓ Branch 1 taken 13862 times.
✓ Branch 2 taken 6709755 times.
✓ Branch 3 taken 181 times.
✓ Branch 4 taken 6709755 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13896 times.
✓ Branch 7 taken 6723651 times.
6723798 if(refilling==REFILL_ALL || flag==mfALLFAIRY||flag2==mfALLFAIRY||flag3==mfALLFAIRY)
24838 {
24839 27939 fairycircle(REFILL_ALL);
24840
24841
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 19 times.
27939 if(fairyclk!=0) return;
24842 19 }
24843
24844 // Just in case Hero was moved off of the fairy flag
24845
1/2
✓ Branch 0 taken 6723670 times.
✗ Branch 1 not taken.
6723670 if(refilling==REFILL_FAIRYDONE)
24846 {
24847 fairycircle(REFILL_NONE);
24848
24849 if(fairyclk!=0) return;
24850 }
24851
24852
6/8
✓ Branch 0 taken 6709764 times.
✓ Branch 1 taken 13906 times.
✓ Branch 2 taken 6709764 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6709764 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13916 times.
✓ Branch 7 taken 6723548 times.
6723670 if(flag==mfZELDA||flag2==mfZELDA||flag3==mfZELDA || combo_class_buf[type].win_game)
24853 {
24854 27822 attackclk = 0; //get rid of Hero's sword if it was stuck out, charged.
24855 27822 win_game();
24856 27822 return;
24857 }
24858
24859
4/4
✓ Branch 0 taken 6691275 times.
✓ Branch 1 taken 32273 times.
✓ Branch 2 taken 6705339 times.
✓ Branch 3 taken 18209 times.
6723548 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS))
24860 18209 return;
24861
24862
4/4
✓ Branch 0 taken 6688924 times.
✓ Branch 1 taken 16415 times.
✓ Branch 2 taken 721 times.
✓ Branch 3 taken 6688203 times.
6705339 if((type==cTRIGNOFLAG || type==cTRIGFLAG))
24863 {
24864
24865
4/4
✓ Branch 0 taken 2089 times.
✓ Branch 1 taken 15047 times.
✓ Branch 2 taken 15415 times.
✓ Branch 3 taken 16616 times.
17136 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepsecret || get_qr(qr_TRIGGERSREPEAT))
24866 {
24867 30462 stepsecret = (((ty+8)&0xF0)+((tx+8)>>4));
24868 30462 sfx(combobuf[tmpscr->data[stepsecret]].attribytes[0],pan((int32_t)x));
24869 //zprint("Step Secrets Sound: %d\n", combobuf[tmpscr->data[stepsecret]].attribytes[0]);
24870
24871
4/4
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 2631 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 198 times.
30462 if(type==cTRIGFLAG && canPermSecret())
24872 {
24873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
24874
24875 198 hidden_entrance(0,true,false);
24876 198 }
24877 else
24878 {
24879 2658 bool only16_31 = get_qr(qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
24880 2658 hidden_entrance(0,true,only16_31);
24881 }
24882 2856 }
24883 19472 }
24884
2/2
✓ Branch 0 taken 1415 times.
✓ Branch 1 taken 6686788 times.
6688203 else if(!didstrig)
24885 {
24886 6686788 stepsecret = -1;
24887 6686788 }
24888
24889 //Better? Dock collision
24890
24891 // Drown if:
24892 // * Water (obviously walkable),
24893 // * Quest Rule allows it,
24894 // * Not on stepladder,
24895 // * Not jumping,
24896 // * Not hovering,
24897 // * Not rafting,
24898 // * Not swallowed,
24899 // * Not a dried lake.
24900
24901 // This used to check for swimming too, but I moved that into the block so that you can drown in higher-leveled water. -Dimi
24902
9/12
✓ Branch 0 taken 16842 times.
✓ Branch 1 taken 6653327 times.
✓ Branch 2 taken 16259 times.
✓ Branch 3 taken 583 times.
✓ Branch 4 taken 16259 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10693 times.
✓ Branch 7 taken 5566 times.
✓ Branch 8 taken 10693 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 10693 times.
6717844 if(water > 0 && !ladderx && hoverclk==0 && action!=rafting && !inlikelike && !DRIEDLAKE
24903
4/8
✓ Branch 0 taken 10693 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10693 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10693 times.
✗ Branch 7 not taken.
10693 && ((get_qr(qr_DROWN) && z==0 && fakez==0 && fall>=0 && fakefall>=0) || CanSideSwim())
24904
4/4
✓ Branch 0 taken 10693 times.
✓ Branch 1 taken 10693 times.
✓ Branch 2 taken 10693 times.
✓ Branch 3 taken 10693 times.
10693 && (sideview_mode() || !platform_ffc))
24905 {
24906
7/8
✓ Branch 0 taken 10504 times.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 10501 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 2518 times.
✓ Branch 5 taken 7983 times.
✓ Branch 6 taken 2518 times.
✗ Branch 7 not taken.
10693 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & item_flag3)))
24907 {
24908
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!(ladderx+laddery)) drownCombo = water;
24909
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 188 times.
192 if (combobuf[water].usrflags&cflag1) Drown(1);
24910 188 else Drown();
24911
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 16 times.
192 if(byte drown_sfx = combobuf[water].attribytes[4])
24912 16 sfx(drown_sfx, pan(int32_t(x)));
24913 192 }
24914
2/2
✓ Branch 0 taken 10237 times.
✓ Branch 1 taken 264 times.
10501 else if (!isSwimming())
24915 {
24916 264 SetSwim();
24917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if (!IsSideSwim()) attackclk = charging = spins = 0;
24918 264 landswim=0;
24919 264 return;
24920 }
24921 10429 }
24922
24923
24924
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 6690957 times.
6691291 if(type==cSTEP)
24925 {
24926
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 186 times.
334 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepnext)
24927 {
24928 186 stepnext=((ty+8)&0xF0)+((tx+8)>>4);
24929
24930 if
24931 (
24932
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 19 times.
186 COMBOTYPE(tx+8,ty+8)==cSTEP && /*required item*/
24933
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167 (!combobuf[tmpscr->data[stepnext]].attribytes[1] || (combobuf[tmpscr->data[stepnext]].attribytes[1] && game->item[combobuf[tmpscr->data[stepnext]].attribytes[1]]) )
24934 && /*HEAVY*/
24935
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
24936 )
24937
24938 {
24939 167 sfx(combobuf[tmpscr->data[stepnext]].attribytes[0],pan((int32_t)x));
24940 167 tmpscr->data[stepnext]++;
24941
24942 167 }
24943
24944 if
24945 (
24946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186 times.
186 COMBOTYPE(tx+8,ty+8)==cSTEPSAME && /*required item*/
24947 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
24948 && /*HEAVY*/
24949 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
24950 )
24951 {
24952 int32_t stepc = tmpscr->data[stepnext];
24953 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
24954 for(int32_t k=0; k<176; k++)
24955 {
24956 if(tmpscr->data[k]==stepc)
24957 {
24958 tmpscr->data[k]++;
24959 }
24960 }
24961 }
24962
24963 if
24964 (
24965
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 179 times.
186 COMBOTYPE(tx+8,ty+8)==cSTEPALL && /*required item*/
24966
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
24967 && /*HEAVY*/
24968
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
24969 )
24970 {
24971 7 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
24972
2/2
✓ Branch 0 taken 1232 times.
✓ Branch 1 taken 7 times.
1239 for(int32_t k=0; k<176; k++)
24973 {
24974 if(
24975
3/4
✓ Branch 0 taken 1232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✓ Branch 3 taken 1051 times.
2382 (combobuf[tmpscr->data[k]].type==cSTEP)||
24976
1/2
✓ Branch 0 taken 1232 times.
✗ Branch 1 not taken.
1232 (combobuf[tmpscr->data[k]].type==cSTEPSAME)||
24977
2/2
✓ Branch 0 taken 1150 times.
✓ Branch 1 taken 82 times.
1232 (combobuf[tmpscr->data[k]].type==cSTEPALL)||
24978 1150 (combobuf[tmpscr->data[k]].type==cSTEPCOPY)
24979 )
24980 {
24981 181 tmpscr->data[k]++;
24982 181 }
24983 1232 }
24984 7 }
24985 186 }
24986 334 }
24987
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6690957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6690957 else if(type==cSTEPSFX && action == walking)
24988 {
24989 trigger_stepfx(0, COMBOPOS(tx+8,ty+8), true);
24990 }
24991 6690957 else stepnext = -1;
24992
24993 6691291 detail_int[0]=tx;
24994 6691291 detail_int[1]=ty;
24995
24996
24997
8/8
✓ Branch 0 taken 6690835 times.
✓ Branch 1 taken 456 times.
✓ Branch 2 taken 877 times.
✓ Branch 3 taken 6690414 times.
✓ Branch 4 taken 6688426 times.
✓ Branch 5 taken 1988 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 11 times.
6691316 if(!((type==cCAVE || type==cCAVE2) && z==0 && fakez==0) && type!=cSTAIR &&
24998
5/6
✓ Branch 0 taken 6687474 times.
✓ Branch 1 taken 952 times.
✓ Branch 2 taken 6687453 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 6687453 times.
✗ Branch 5 not taken.
6688426 type!=cPIT && type!=cSWIMWARP && type!=cRESET &&
24999
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 6687428 times.
6687453 !(type==cDIVEWARP && isDiving()))
25000 6687439 {
25001 RaftingStuff:
25002
2/2
✓ Branch 0 taken 6686880 times.
✓ Branch 1 taken 559 times.
6687439 if (get_qr(qr_BETTER_RAFT_2))
25003 {
25004 559 bool doraft = true;
25005
4/6
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 556 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
559 if(((int32_t)y>=raftwarpy-12&&(int32_t)y<=raftwarpy+3)&&raftwarpy!=-1)
25006 {
25007
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
25008 {
25009 3 doraft = false;
25010 3 }
25011 3 }
25012 //if (mfRAFT)
25013 int32_t rafttypes[2];
25014 559 int32_t raftx1 = tx+6;
25015 559 int32_t raftx2 = tx+9;
25016 559 int32_t rafty = ty+11;
25017 int32_t raftflags[3];
25018 559 rafttypes[0]=rafttypes[1]=-1;
25019 559 raftflags[0]=raftflags[1]=raftflags[2]=0;
25020 559 rafttypes[0] = MAPFLAG(raftx1,rafty);
25021 559 rafttypes[1] = MAPFLAG(raftx2,rafty);
25022
25023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
25024 559 raftflags[0] = rafttypes[0];
25025
25026
25027 559 rafttypes[0] = MAPCOMBOFLAG(raftx1,rafty);
25028 559 rafttypes[1] = MAPCOMBOFLAG(raftx2,rafty);
25029
25030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
25031 559 raftflags[1] = rafttypes[0];
25032
25033 559 rafttypes[0] = MAPFFCOMBOFLAG(raftx1,rafty);
25034 559 rafttypes[1] = MAPFFCOMBOFLAG(raftx2,rafty);
25035
25036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
25037 559 raftflags[2] = rafttypes[0];
25038
25039
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 559 times.
2236 for (int32_t m = 0; m < 3; ++m)
25040 {
25041
2/4
✓ Branch 0 taken 1677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1677 times.
1677 if (raftflags[m] == mfRAFT || raftflags[m] == mfRAFT_BRANCH)
25042 {
25043 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && (combo_class_buf[COMBOTYPE(tx+8, ty+11)].dock || combo_class_buf[FFCOMBOTYPE(tx+8, ty+11)].dock))
25044 {
25045 if((isRaftFlag(nextflag(tx,ty+11,dir,false))||isRaftFlag(nextflag(tx,ty+11,dir,true))))
25046 {
25047 reset_swordcharge();
25048 action=rafting; FFCore.setHeroAction(rafting);
25049 raftclk=0;
25050 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25051 else sfx(tmpscr->secretsfx);
25052 }
25053 else if (get_qr(qr_BETTER_RAFT) && doraft)
25054 {
25055 for (int32_t i = 0; i < 4; ++i)
25056 {
25057 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,true)))
25058 {
25059 reset_swordcharge();
25060 action=rafting; FFCore.setHeroAction(rafting);
25061 raftclk=0;
25062 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25063 else sfx(tmpscr->secretsfx);
25064 dir = i;
25065 break;
25066 }
25067 }
25068 }
25069 }
25070 }
25071 1677 }
25072 559 }
25073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6687439 times.
6687439 if (RaftPass) return;
25074
3/3
✓ Branch 0 taken 34031 times.
✓ Branch 1 taken 6652348 times.
✓ Branch 2 taken 1060 times.
6687439 switch(flag)
25075 {
25076 case mfDIVE_ITEM:
25077
6/8
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1036 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
1060 if(isDiving() && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
25078 {
25079 30 additem(x, y, tmpscr->catchall,
25080 15 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
25081 15 sfx(tmpscr->secretsfx);
25082 15 }
25083
25084 1060 return;
25085
25086 case mfRAFT:
25087 case mfRAFT_BRANCH:
25088
25089 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
25090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34031 times.
34031 if (!get_qr(qr_BETTER_RAFT_2))
25091 {
25092 34031 bool doraft = true;
25093
5/6
✓ Branch 0 taken 34031 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2122 times.
✓ Branch 3 taken 31909 times.
✓ Branch 4 taken 576 times.
✓ Branch 5 taken 1546 times.
34031 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
25094 {
25095
5/6
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✓ Branch 3 taken 738 times.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 785 times.
1546 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
25096 {
25097 785 doraft = false;
25098 785 }
25099 1546 }
25100
13/16
✓ Branch 0 taken 31056 times.
✓ Branch 1 taken 2975 times.
✓ Branch 2 taken 3282 times.
✓ Branch 3 taken 27774 times.
✓ Branch 4 taken 3262 times.
✓ Branch 5 taken 20 times.
✓ Branch 6 taken 3251 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 3251 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3251 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3251 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1531 times.
✓ Branch 15 taken 1720 times.
34031 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
25101 {
25102
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
1720 if(isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true)))
25103 {
25104 355 reset_swordcharge();
25105 355 action=rafting; FFCore.setHeroAction(rafting);
25106 355 raftclk=0;
25107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 355 times.
355 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25108 355 else sfx(tmpscr->secretsfx);
25109 355 }
25110
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1365 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1365 else if (get_qr(qr_BETTER_RAFT) && doraft)
25111 {
25112 for (int32_t i = 0; i < 4; ++i)
25113 {
25114 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
25115 {
25116 reset_swordcharge();
25117 action=rafting; FFCore.setHeroAction(rafting);
25118 raftclk=0;
25119 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25120 else sfx(tmpscr->secretsfx);
25121 dir = i;
25122 break;
25123 }
25124 }
25125 }
25126 1720 }
25127 34031 }
25128
25129 34031 return;
25130
25131 default:
25132 6652348 break;
25133 //return;
25134 }
25135
25136
2/3
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 6652074 times.
✗ Branch 2 not taken.
6652348 switch(flag2)
25137 {
25138 case mfDIVE_ITEM:
25139 if(isDiving() && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
25140 {
25141 additem(x, y, tmpscr->catchall,
25142 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
25143 sfx(tmpscr->secretsfx);
25144 }
25145
25146 return;
25147
25148 case mfRAFT:
25149 case mfRAFT_BRANCH:
25150
25151 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
25152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
274 if (!get_qr(qr_BETTER_RAFT_2))
25153 {
25154 274 bool doraft = true;
25155
2/6
✓ Branch 0 taken 274 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 274 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
274 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
25156 {
25157 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
25158 {
25159 doraft = false;
25160 }
25161 }
25162
10/16
✓ Branch 0 taken 274 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✓ Branch 3 taken 139 times.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 135 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 135 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 121 times.
✓ Branch 15 taken 14 times.
274 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
25163 {
25164
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 9 times.
14 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
25165 {
25166 5 reset_swordcharge();
25167 5 action=rafting; FFCore.setHeroAction(rafting);
25168 5 raftclk=0;
25169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25170 5 else sfx(tmpscr->secretsfx);
25171 5 }
25172
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 else if (get_qr(qr_BETTER_RAFT) && doraft)
25173 {
25174 for (int32_t i = 0; i < 4; ++i)
25175 {
25176 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
25177 {
25178 reset_swordcharge();
25179 action=rafting; FFCore.setHeroAction(rafting);
25180 raftclk=0;
25181 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25182 else sfx(tmpscr->secretsfx);
25183 dir = i;
25184 break;
25185 }
25186 }
25187 }
25188 14 }
25189 274 }
25190
25191 274 return;
25192
25193 default:
25194 6652074 break;
25195 //return;
25196 }
25197
25198
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6652074 times.
✗ Branch 2 not taken.
6652074 switch(flag3)
25199 {
25200 case mfDIVE_ITEM:
25201 if(isDiving() && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
25202 {
25203 additem(x, y, tmpscr->catchall,
25204 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
25205 sfx(tmpscr->secretsfx);
25206 }
25207
25208 return;
25209
25210 case mfRAFT:
25211 case mfRAFT_BRANCH:
25212
25213 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
25214 if (!get_qr(qr_BETTER_RAFT_2))
25215 {
25216 bool doraft = true;
25217 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
25218 {
25219 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
25220 {
25221 doraft = false;
25222 }
25223 }
25224 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
25225 {
25226 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
25227 {
25228 reset_swordcharge();
25229 action=rafting; FFCore.setHeroAction(rafting);
25230 raftclk=0;
25231 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25232 else sfx(tmpscr->secretsfx);
25233 }
25234 else if (get_qr(qr_BETTER_RAFT) && doraft)
25235 {
25236 for (int32_t i = 0; i < 4; ++i)
25237 {
25238 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
25239 {
25240 reset_swordcharge();
25241 action=rafting; FFCore.setHeroAction(rafting);
25242 raftclk=0;
25243 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25244 else sfx(tmpscr->secretsfx);
25245 dir = i;
25246 break;
25247 }
25248 }
25249 }
25250 }
25251 }
25252
25253 return;
25254
25255 default:
25256 6652074 return;
25257 }
25258 }
25259
25260
25261 3852 int32_t t=(currscr<128)?0:1;
25262
25263
3/4
✓ Branch 0 taken 3396 times.
✓ Branch 1 taken 456 times.
✓ Branch 2 taken 3852 times.
✗ Branch 3 not taken.
3852 if((type==cCAVE || type==cCAVE2) && (tmpscr[t].tilewarptype[index]==wtNOWARP)) return;
25264
25265 //don't do this for canceled warps -DD
25266 //I have no idea why we do this skip, but I'll dutifully propagate it to all cases below...
25267 /*if(tmpscr[t].tilewarptype[index] != wtNOWARP)
25268 {
25269 draw_screen(tmpscr);
25270 advanceframe(true);
25271 }*/
25272
25273 3852 bool skippedaframe=false;
25274
25275
6/6
✓ Branch 0 taken 3396 times.
✓ Branch 1 taken 456 times.
✓ Branch 2 taken 2975 times.
✓ Branch 3 taken 421 times.
✓ Branch 4 taken 1988 times.
✓ Branch 5 taken 987 times.
3852 if(type==cCAVE || type==cCAVE2 || type==cSTAIR)
25276 {
25277 // Stop music only if:
25278 // * entering a Guy Cave
25279 // * warping to a DMap whose music is different.
25280
25281 2865 int32_t tdm = tmpscr[t].tilewarpdmap[index];
25282
25283
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 1910 times.
2865 if(tmpscr[t].tilewarptype[index]<=wtPASS)
25284 {
25285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 955 times.
955 if (FFCore.can_dmap_change_music(tdm))
25286 {
25287
3/4
✓ Branch 0 taken 486 times.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 486 times.
955 if ((DMaps[currdmap].flags & dmfCAVES) && tmpscr[t].tilewarptype[index] == wtCAVE)
25288 486 music_stop();
25289 955 }
25290 955 }
25291 else
25292 {
25293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1910 times.
1910 if (FFCore.can_dmap_change_music(tdm))
25294 {
25295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1910 times.
1910 if (zcmusic != NULL)
25296 {
25297 if (strcmp(zcmusic->filename, DMaps[tdm].tmusic) != 0 ||
25298 (zcmusic->type == ZCMF_GME && zcmusic->track != DMaps[tdm].tmusictrack))
25299 music_stop();
25300 }
25301
3/4
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1908 times.
1910 else if (DMaps[tmpscr->tilewarpdmap[index]].midi != (currmidi - ZC_MIDI_COUNT + 4) &&
25302 1908 TheMaps[(DMaps[tdm].map * MAPSCRS + (tmpscr[t].tilewarpscr[index] + DMaps[tdm].xoff))].screen_midi != (currmidi - ZC_MIDI_COUNT + 4))
25303 1908 music_stop();
25304 1910 }
25305 }
25306
25307 2865 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25308
5/6
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 1910 times.
✓ Branch 2 taken 486 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 486 times.
2865 bool opening = (tmpscr[t].tilewarptype[index]<=wtPASS && !(DMaps[currdmap].flags&dmfCAVES && tmpscr[t].tilewarptype[index]==wtCAVE)
25309 2396 ? false : COOLSCROLL);
25310
25311 2865 FFCore.warpScriptCheck();
25312 2865 draw_screen(tmpscr);
25313 2865 advanceframe(true);
25314
25315 2865 skippedaframe=true;
25316
25317
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 2444 times.
2865 if(type==cCAVE2) walkup2(opening);
25318
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 456 times.
2444 else if(type==cCAVE) walkdown(opening);
25319 2865 }
25320
25321
2/2
✓ Branch 0 taken 2900 times.
✓ Branch 1 taken 952 times.
3852 if(type==cPIT)
25322 {
25323 952 didpit=true;
25324 952 pitx=x;
25325 952 pity=y;
25326 952 warp_sound = warpsfx2;
25327 952 }
25328
25329
5/6
✓ Branch 0 taken 1293 times.
✓ Branch 1 taken 2559 times.
✓ Branch 2 taken 1236 times.
✓ Branch 3 taken 57 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 57 times.
3909 if(DMaps[currdmap].flags&dmf3STAIR && (currscr==129 || !(DMaps[currdmap].flags&dmfGUYCAVES))
25330
2/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
1293 && tmpscr[specialcave > 0 && DMaps[currdmap].flags&dmfGUYCAVES ? 1:0].room==rWARP && type==cSTAIR)
25331 {
25332
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(!skippedaframe)
25333 {
25334 FFCore.warpScriptCheck();
25335 draw_screen(tmpscr);
25336 advanceframe(true);
25337 }
25338
25339 // "take any road you want"
25340
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 11 times.
57 int32_t dw = x<112 ? 1 : (x>136 ? 3 : 2);
25341 57 int32_t code = WARPCODE(currdmap,homescr,dw);
25342
25343
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(code>-1)
25344 {
25345 57 bool changedlevel = false;
25346 57 bool changeddmap = false;
25347
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 15 times.
57 if(currdmap != code>>8)
25348 {
25349 15 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
25350 15 changeddmap = true;
25351 15 }
25352
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(dlevel != DMaps[code>>8].level)
25353 {
25354 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
25355 changedlevel = true;
25356 }
25357 57 currdmap = code>>8;
25358 57 dlevel = DMaps[currdmap].level;
25359
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 15 times.
57 if(changeddmap)
25360 {
25361 15 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
25362 15 }
25363
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(changedlevel)
25364 {
25365 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
25366 }
25367
25368 57 currmap = DMaps[currdmap].map;
25369 57 homescr = (code&0xFF) + DMaps[currdmap].xoff;
25370 57 init_dmap();
25371
25372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(canPermSecret())
25373 57 setmapflag(mSECRET);
25374 57 }
25375
25376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(specialcave==STAIRCAVE) exitcave();
25377
25378 57 return;
25379 }
25380
25381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3795 times.
3795 if(type==cRESET)
25382 {
25383 if(!skippedaframe)
25384 {
25385 FFCore.warpScriptCheck();
25386 draw_screen(tmpscr);
25387 advanceframe(true);
25388 }
25389
25390 if(!(tmpscr->noreset&mSECRET)) unsetmapflag(mSECRET);
25391
25392 if(!(tmpscr->noreset&mITEM)) unsetmapflag(mITEM);
25393
25394 if(!(tmpscr->noreset&mSPECIALITEM)) unsetmapflag(mSPECIALITEM);
25395
25396 if(!(tmpscr->noreset&mNEVERRET)) unsetmapflag(mNEVERRET);
25397
25398 if(!(tmpscr->noreset&mCHEST)) unsetmapflag(mCHEST);
25399
25400 if(!(tmpscr->noreset&mLOCKEDCHEST)) unsetmapflag(mLOCKEDCHEST);
25401
25402 if(!(tmpscr->noreset&mBOSSCHEST)) unsetmapflag(mBOSSCHEST);
25403
25404 if(!(tmpscr->noreset&mLOCKBLOCK)) unsetmapflag(mLOCKBLOCK);
25405
25406 if(!(tmpscr->noreset&mBOSSLOCKBLOCK)) unsetmapflag(mBOSSLOCKBLOCK);
25407
25408 if(isdungeon())
25409 {
25410 if(!(tmpscr->noreset&mDOOR_LEFT)) unsetmapflag(mDOOR_LEFT);
25411
25412 if(!(tmpscr->noreset&mDOOR_RIGHT)) unsetmapflag(mDOOR_RIGHT);
25413
25414 if(!(tmpscr->noreset&mDOOR_DOWN)) unsetmapflag(mDOOR_DOWN);
25415
25416 if(!(tmpscr->noreset&mDOOR_UP)) unsetmapflag(mDOOR_UP);
25417 }
25418
25419 didpit=true;
25420 pitx=x;
25421 pity=y;
25422 sdir=dir;
25423 dowarp(4,0, warpsfx2);
25424 }
25425 else
25426 {
25427
3/4
✓ Branch 0 taken 987 times.
✓ Branch 1 taken 2808 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 987 times.
3795 if(!skippedaframe && (tmpscr[t].tilewarptype[index]!=wtNOWARP))
25428 {
25429 987 FFCore.warpScriptCheck();
25430 987 draw_screen(tmpscr);
25431 987 advanceframe(true);
25432 987 }
25433
25434 3795 sdir = dir;
25435 3795 dowarp(0,index, warpsfx2);
25436 }
25437 14098762 }
25438
25439 112 int32_t selectWlevel(int32_t d)
25440 {
25441
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(TriforceCount()==0)
25442 return 0;
25443
25444 112 word l = game->get_wlevel();
25445
25446 112 do
25447 {
25448
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
185 if(d==0 && (game->lvlitems[l+1] & liTRIFORCE))
25449 break;
25450
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 72 times.
185 else if(d<0)
25451
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 14 times.
72 l = (l==0) ? 7 : l-1;
25452 else
25453
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 97 times.
113 l = (l==7) ? 0 : l+1;
25454
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 112 times.
185 }
25455 185 while(!(game->lvlitems[l+1] & liTRIFORCE));
25456
25457 112 game->set_wlevel(l);
25458 112 return l;
25459 112 }
25460
25461 // Would someone tell the Dodongos to shut their yaps?!
25462 27555 void kill_enemy_sfx()
25463 {
25464
2/2
✓ Branch 0 taken 27555 times.
✓ Branch 1 taken 54826 times.
82381 for(int32_t i=0; i<guys.Count(); i++)
25465 {
25466
2/2
✓ Branch 0 taken 20274 times.
✓ Branch 1 taken 34552 times.
54826 if(((enemy*)guys.spr(i))->bgsfx)
25467 34552 stop_sfx(((enemy*)guys.spr(i))->bgsfx);
25468 54826 }
25469
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 27444 times.
27555 if (Hero.action!=inwind) stop_sfx(WAV_ZN1WHIRLWIND);
25470
2/2
✓ Branch 0 taken 27539 times.
✓ Branch 1 taken 16 times.
27555 if(tmpscr->room==rGANON)
25471 16 stop_sfx(WAV_ROAR);
25472 27555 }
25473
25474 3271 bool HeroClass::HasHeavyBoots()
25475 {
25476
2/2
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 837376 times.
840647 for ( int32_t q = 0; q < MAXITEMS; ++q )
25477 {
25478
3/6
✓ Branch 0 taken 68711 times.
✓ Branch 1 taken 768665 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68711 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
837376 if ( game->item[q] && ( itemsbuf[q].family == itype_boots ) && /*iron*/ (itemsbuf[q].flags&item_flag2) ) return true;
25479 837376 }
25480 3271 return false;
25481 3271 }
25482
25483 7232 bool HeroClass::dowarp(int32_t type, int32_t index, int32_t warpsfx)
25484 {
25485 7232 byte reposition_sword_postwarp = 0;
25486
1/2
✓ Branch 0 taken 7232 times.
✗ Branch 1 not taken.
7232 if(index<0)
25487 {
25488 return false;
25489 }
25490 7232 is_warping = true;
25491
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 7232 times.
7987 for ( int32_t q = 0; q < Lwpns.Count(); ++q )
25492 {
25493 755 weapon *swd=NULL;
25494 755 swd = (weapon*)Lwpns.spr(q);
25495
2/2
✓ Branch 0 taken 685 times.
✓ Branch 1 taken 70 times.
755 if(swd->id == (attack==wSword ? wSword : wWand))
25496 {
25497 70 Lwpns.del(q);
25498 70 }
25499 755 }
25500
25501 7232 attackclk = charging = spins = tapping = 0;
25502 7232 attack = none;
25503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7232 times.
7232 if ( warp_sound > 0 ) warpsfx = warp_sound;
25504 7232 warp_sound = 0;
25505 7232 word wdmap=0;
25506 7232 byte wscr=0,wtype=0,t=0;
25507 7232 bool overlay=false;
25508 7232 t=(currscr<128)?0:1;
25509 7232 int32_t wrindex = 0;
25510 7232 bool wasSideview = isSideViewGravity(t); // (tmpscr[t].flags7 & fSIDEVIEW)!=0 && !ignoreSideview;
25511
25512 // Drawing commands probably shouldn't carry over...
25513
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 6848 times.
7232 if ( !get_qr(qr_SCRIPTDRAWSINWARPS) )
25514 6848 script_drawing_commands.Clear();
25515
25516
4/6
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 3838 times.
✓ Branch 2 taken 2899 times.
✓ Branch 3 taken 111 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7232 switch(type)
25517 {
25518 case 0: // tile warp
25519 3838 wtype = tmpscr[t].tilewarptype[index];
25520 3838 wdmap = tmpscr[t].tilewarpdmap[index];
25521 3838 wscr = tmpscr[t].tilewarpscr[index];
25522 3838 overlay = get_bit(&tmpscr[t].tilewarpoverlayflags,index)?1:0;
25523 3838 wrindex=(tmpscr->warpreturnc>>(index*2))&3;
25524 3838 break;
25525
25526 case 1: // side warp
25527 2899 wtype = tmpscr[t].sidewarptype[index];
25528 2899 wdmap = tmpscr[t].sidewarpdmap[index];
25529 2899 wscr = tmpscr[t].sidewarpscr[index];
25530 2899 overlay = get_bit(&tmpscr[t].sidewarpoverlayflags,index)?1:0;
25531 2899 wrindex=(tmpscr->warpreturnc>>(8+(index*2)))&3;
25532 //tmpscr->doscript = 0; //kill the currebt screen's script so that it does not continue to run during the scroll.
25533 //there is no doscript for screen scripts. They run like ffcs.
25534
25535 2899 break;
25536
25537 case 2: // whistle warp
25538 {
25539 111 wtype = wtWHISTLE;
25540
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 int32_t wind = whistleitem>-1 ? itemsbuf[whistleitem].misc2 : 8;
25541 111 int32_t level=0;
25542
25543
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(blowcnt==0)
25544 level = selectWlevel(0);
25545 else
25546 {
25547
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 111 times.
223 for(int32_t i=0; i<abs(blowcnt); i++)
25548 112 level = selectWlevel(blowcnt);
25549 }
25550
25551
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111 if(level > QMisc.warp[wind].size && QMisc.warp[wind].size>0)
25552 {
25553 level %= QMisc.warp[wind].size;
25554 game->set_wlevel(level);
25555 }
25556
25557 111 wdmap = QMisc.warp[wind].dmap[level];
25558 111 wscr = QMisc.warp[wind].scr[level];
25559 }
25560 111 break;
25561
25562 case 3:
25563 wtype = wtIWARP;
25564 wdmap = cheat_goto_dmap;
25565 wscr = cheat_goto_screen;
25566 break;
25567
25568 case 4:
25569 wtype = wtIWARP;
25570 wdmap = currdmap;
25571 wscr = homescr-DMaps[currdmap].xoff;
25572 break;
25573 }
25574
25575 7232 bool intradmap = (wdmap == currdmap);
25576 7232 int32_t olddmap = currdmap;
25577 7232 rehydratelake(type!=wtSCROLL);
25578 7232 bool updatemusic = FFCore.can_dmap_change_music(wdmap);
25579 7232 bool musicnocut = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_NOCUT;
25580 7232 bool musicrevert = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_REVERT;
25581
25582
7/8
✓ Branch 0 taken 3588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 583 times.
✓ Branch 3 taken 322 times.
✓ Branch 4 taken 1636 times.
✓ Branch 5 taken 841 times.
✓ Branch 6 taken 111 times.
✓ Branch 7 taken 151 times.
7232 switch(wtype)
25583 {
25584 case wtCAVE:
25585 {
25586 // cave/item room
25587 583 ALLOFF();
25588 583 homescr=currscr;
25589 583 currscr=0x80;
25590
25591
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 154 times.
583 if(DMaps[currdmap].flags&dmfCAVES) // cave
25592 {
25593
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
429 if (updatemusic || !musicnocut || !get_qr(qr_SCREEN80_OWN_MUSIC))
25594 429 music_stop();
25595 429 kill_sfx();
25596
25597
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 367 times.
429 if(tmpscr->room==rWARP)
25598 {
25599 62 currscr=0x81;
25600 62 specialcave = STAIRCAVE;
25601 62 }
25602 367 else specialcave = GUYCAVE;
25603
25604 //lighting(2,dir);
25605 429 lighting(false, true);
25606 429 loadlvlpal(10);
25607
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 63 times.
795 bool b2 = COOLSCROLL&&
25608
3/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 159 times.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
366 ((combobuf[MAPCOMBO(x,y-16)].type==cCAVE)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2)||
25609
2/4
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
207 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEB)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2B)||
25610
2/4
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
207 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEC)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2C)||
25611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207 times.
207 (combobuf[MAPCOMBO(x,y-16)].type==cCAVED)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2D));
25612 429 blackscr(30,b2?false:true);
25613 429 loadscr(0,wdmap,currscr,up,false);
25614 429 loadscr(1,wdmap,homescr,up,false);
25615 //preloaded freeform combos
25616 429 ffscript_engine(true);
25617 429 putscr(scrollbuf,0,0,tmpscr);
25618 429 putscrdoors(scrollbuf,0,0,tmpscr);
25619 429 dir=up;
25620 429 x=112;
25621 429 y=160;
25622
1/2
✓ Branch 0 taken 429 times.
✗ Branch 1 not taken.
429 if(didpit)
25623 {
25624 didpit=false;
25625 x=pitx;
25626 y=pity;
25627 }
25628
25629 429 reset_hookshot();
25630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
429 if(reposition_sword_postwarp)
25631 {
25632 weapon *swd=NULL;
25633 for(int32_t i=0; i<Lwpns.Count(); i++)
25634 {
25635 swd = (weapon*)Lwpns.spr(i);
25636
25637 if(swd->id == (attack==wSword ? wSword : wWand))
25638 {
25639 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25640 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25641 positionSword(swd,item_id);
25642 break;
25643 }
25644 }
25645 }
25646 429 stepforward(diagonalMovement?5:6, false);
25647 429 }
25648 else // item room
25649 {
25650 154 specialcave = ITEMCELLAR;
25651 154 kill_sfx();
25652 154 draw_screen(tmpscr,false);
25653
25654 //unless the room is already dark, fade to black
25655
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 153 times.
154 if (!get_qr(qr_NEW_DARKROOM))
25656 {
25657
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 152 times.
153 if(!darkroom)
25658 {
25659 152 darkroom = true;
25660 152 fade(DMaps[currdmap].color,true,false);
25661 152 }
25662 153 }
25663 else
25664 1 fade(DMaps[currdmap].color, true, false);
25665
25666 154 blackscr(30,true);
25667 154 loadscr(0,wdmap,currscr,down,false);
25668 154 loadscr(1,wdmap,homescr,-1,false);
25669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if ( dontdraw < 2 ) { dontdraw=1; }
25670 154 draw_screen(tmpscr, false);
25671 154 fade(0xB,true,true);
25672 154 darkroom = false;
25673 154 dir=down;
25674 154 x=48;
25675 154 y=0;
25676
25677 // is this didpit check necessary?
25678
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 1 times.
154 if(didpit)
25679 {
25680 1 didpit=false;
25681 1 x=pitx;
25682 1 y=pity;
25683 1 }
25684
25685 154 reset_hookshot();
25686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if(reposition_sword_postwarp)
25687 {
25688 weapon *swd=NULL;
25689 for(int32_t i=0; i<Lwpns.Count(); i++)
25690 {
25691 swd = (weapon*)Lwpns.spr(i);
25692
25693 if(swd->id == (attack==wSword ? wSword : wWand))
25694 {
25695 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25696 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25697 positionSword(swd,item_id);
25698 break;
25699 }
25700 }
25701 }
25702 154 lighting(false, true);
25703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if ( dontdraw < 2 ) { dontdraw=0; }
25704 154 stepforward(diagonalMovement?16:18, false);
25705 }
25706
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 583 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
583 if (get_qr(qr_SCREEN80_OWN_MUSIC) && (updatemusic || !musicnocut))
25707 {
25708 playLevelMusic();
25709 if (musicrevert)
25710 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
25711 }
25712 583 break;
25713 }
25714
25715 case wtPASS: // passageway
25716 {
25717 322 kill_sfx();
25718 322 ALLOFF();
25719 //play sound
25720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
25721 322 homescr=currscr;
25722 322 currscr=0x81;
25723 322 specialcave = PASSAGEWAY;
25724 322 byte warpscr2 = wscr + DMaps[wdmap].xoff;
25725 322 draw_screen(tmpscr,false);
25726
25727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if(!get_qr(qr_NEW_DARKROOM))
25728 {
25729
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 314 times.
322 if(!darkroom)
25730 314 fade(DMaps[currdmap].color,true,false);
25731
25732 322 darkroom=true;
25733 322 }
25734 else
25735 fade(DMaps[currdmap].color,true,false);
25736 322 blackscr(30,true);
25737 322 loadscr(0,wdmap,currscr,down,false);
25738 322 loadscr(1,wdmap,homescr,-1,false);
25739 //preloaded freeform combos
25740 322 ffscript_engine(true);
25741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if ( dontdraw < 2 ) { dontdraw=1; }
25742 322 draw_screen(tmpscr, false);
25743 322 lighting(false, true);
25744
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if (get_qr(qr_NEW_DARKROOM))
25745 fade(0xB, false, true);
25746 322 dir=down;
25747 322 x=48;
25748
25749
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 174 times.
322 if((homescr&15) > (warpscr2&15))
25750 {
25751 174 x=192;
25752 174 }
25753
25754
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 12 times.
322 if((homescr&15) == (warpscr2&15))
25755 {
25756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if((currscr>>4) > (warpscr2>>4))
25757 {
25758 12 x=192;
25759 12 }
25760 12 }
25761
25762 // is this didpit check necessary?
25763
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if(didpit)
25764 {
25765 didpit=false;
25766 x=pitx;
25767 y=pity;
25768 }
25769
25770 322 y=0;
25771 322 set_respawn_point();
25772 322 trySideviewLadder();
25773 322 reset_hookshot();
25774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if(reposition_sword_postwarp)
25775 {
25776 weapon *swd=NULL;
25777 for(int32_t i=0; i<Lwpns.Count(); i++)
25778 {
25779 swd = (weapon*)Lwpns.spr(i);
25780
25781 if(swd->id == (attack==wSword ? wSword : wWand))
25782 {
25783 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25784 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25785 positionSword(swd,item_id);
25786 break;
25787 }
25788 }
25789 }
25790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if ( dontdraw < 2 ) { dontdraw=0; }
25791 322 stepforward(diagonalMovement?16:18, false);
25792 322 newscr_clk=frame;
25793 322 activated_timed_warp=false;
25794 322 stepoutindex=index;
25795 322 stepoutscr = warpscr2;
25796 322 stepoutdmap = wdmap;
25797 322 stepoutwr=wrindex;
25798
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
322 if (get_qr(qr_SCREEN80_OWN_MUSIC) && (updatemusic || !musicnocut))
25799 {
25800 playLevelMusic();
25801 if (musicrevert)
25802 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
25803 }
25804 }
25805 322 break;
25806
25807 case wtEXIT: // entrance/exit
25808 {
25809 1636 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
25810 1636 ALLOFF();
25811
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1636 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1636 if(updatemusic||!musicnocut)
25812 1636 music_stop();
25813 1636 kill_sfx();
25814 1636 blackscr(30,false);
25815 1636 bool changedlevel = false;
25816 1636 bool changeddmap = false;
25817
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1633 times.
1636 if(currdmap != wdmap)
25818 {
25819 1633 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
25820 1633 changeddmap = true;
25821 1633 }
25822
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 1374 times.
1636 if(dlevel != DMaps[wdmap].level)
25823 {
25824 1374 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
25825 1374 changedlevel = true;
25826 1374 }
25827 1636 dlevel = DMaps[wdmap].level;
25828 1636 currdmap = wdmap;
25829
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1633 times.
1636 if(changeddmap)
25830 {
25831 1633 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
25832 1633 }
25833
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 1374 times.
1636 if(changedlevel)
25834 {
25835 1374 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
25836 1374 }
25837
25838 1636 currmap=DMaps[currdmap].map;
25839 1636 init_dmap();
25840 1636 update_subscreens(wdmap);
25841 1636 loadfullpal();
25842 1636 ringcolor(false);
25843 1636 loadlvlpal(DMaps[currdmap].color);
25844 //lastentrance_dmap = currdmap;
25845 1636 homescr = currscr = wscr + DMaps[currdmap].xoff;
25846 1636 loadscr(0,currdmap,currscr,-1,overlay);
25847
25848
4/4
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 1580 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 10 times.
1636 if((tmpscr->flags&fDARK) && !get_qr(qr_NEW_DARKROOM))
25849 {
25850
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 if(get_qr(qr_FADE))
25851 {
25852 7 interpolatedfade();
25853 7 }
25854 else
25855 {
25856 3 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
25857 }
25858
25859 10 darkroom=naturaldark=true;
25860 10 }
25861 else
25862 {
25863 1626 darkroom=naturaldark=false;
25864 }
25865
25866 int32_t wrx,wry;
25867
25868
2/2
✓ Branch 0 taken 655 times.
✓ Branch 1 taken 981 times.
1636 if(get_qr(qr_NOARRIVALPOINT))
25869 {
25870 655 wrx=tmpscr->warpreturnx[0];
25871 655 wry=tmpscr->warpreturny[0];
25872 655 }
25873 else
25874 {
25875 981 wrx=tmpscr->warparrivalx;
25876 981 wry=tmpscr->warparrivaly;
25877 }
25878
25879
6/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 1545 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 1573 times.
1636 if(((wrx>0||wry>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
25880 {
25881
2/2
✓ Branch 0 taken 1113 times.
✓ Branch 1 taken 460 times.
1573 if(dlevel)
25882 {
25883 1113 lastentrance = currscr;
25884 1113 }
25885 else
25886 {
25887 460 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
25888 }
25889
25890 1573 lastentrance_dmap = wdmap;
25891 1573 }
25892
25893
2/2
✓ Branch 0 taken 1113 times.
✓ Branch 1 taken 523 times.
1636 if(dlevel)
25894 {
25895
2/2
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 554 times.
1113 if(get_qr(qr_NOARRIVALPOINT))
25896 {
25897 559 x=tmpscr->warpreturnx[wrindex];
25898 559 y=tmpscr->warpreturny[wrindex];
25899 559 }
25900 else
25901 {
25902 554 x=tmpscr->warparrivalx;
25903 554 y=tmpscr->warparrivaly;
25904 }
25905 1113 }
25906 else
25907 {
25908 523 x=tmpscr->warpreturnx[wrindex];
25909 523 y=tmpscr->warpreturny[wrindex];
25910 }
25911
25912
2/2
✓ Branch 0 taken 1627 times.
✓ Branch 1 taken 9 times.
1636 if(didpit)
25913 {
25914 9 didpit=false;
25915 9 x=pitx;
25916 9 y=pity;
25917 9 }
25918
25919 1636 dir=down;
25920
25921
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 1608 times.
1636 if(x==0) dir=right;
25922
25923
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1613 times.
1636 if(x==240) dir=left;
25924
25925
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1598 times.
1636 if(y==0) dir=down;
25926
25927
2/2
✓ Branch 0 taken 628 times.
✓ Branch 1 taken 1008 times.
1636 if(y==160) dir=up;
25928
25929
2/2
✓ Branch 0 taken 1113 times.
✓ Branch 1 taken 523 times.
1636 if(dlevel)
25930 {
25931 // reset enemy kill counts
25932
2/2
✓ Branch 0 taken 142464 times.
✓ Branch 1 taken 1113 times.
143577 for(int32_t i=0; i<128; i++)
25933 {
25934 142464 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
25935 142464 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
25936 142464 }
25937 1113 }
25938
25939 1636 markBmap(dir^1);
25940 //preloaded freeform combos
25941 1636 ffscript_engine(true);
25942
25943 1636 reset_hookshot();
25944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1636 times.
1636 if(reposition_sword_postwarp)
25945 {
25946 weapon *swd=NULL;
25947 for(int32_t i=0; i<Lwpns.Count(); i++)
25948 {
25949 swd = (weapon*)Lwpns.spr(i);
25950
25951 if(swd->id == (attack==wSword ? wSword : wWand))
25952 {
25953 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25954 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25955 positionSword(swd,item_id);
25956 break;
25957 }
25958 }
25959 }
25960
25961
2/2
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 1163 times.
1636 if(isdungeon())
25962 {
25963 473 openscreen();
25964
4/4
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 374 times.
473 if(get_er(er_SHORTDGNWALK)==0 && get_qr(qr_SHORTDGNWALK)==0)
25965 374 stepforward(diagonalMovement?11:12, false);
25966 else
25967 // Didn't walk as far pre-1.93, and some quests depend on that
25968 99 stepforward(8, false);
25969 473 }
25970 else
25971 {
25972
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 996 times.
1163 if(!COOLSCROLL)
25973 167 openscreen();
25974
25975 1163 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type; // Old-style blue square placement
25976 1163 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
25977 1163 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type; // More old-style blue square placement
25978
25979
10/10
✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1004 times.
✓ Branch 5 taken 38 times.
✓ Branch 6 taken 27 times.
✓ Branch 7 taken 977 times.
✓ Branch 8 taken 27 times.
✓ Branch 9 taken 54 times.
1163 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
25980 {
25981 204 reset_pal_cycling();
25982 204 putscr(scrollbuf,0,0,tmpscr);
25983 204 putscrdoors(scrollbuf,0,0,tmpscr);
25984 204 walkup(COOLSCROLL);
25985 204 }
25986
10/10
✓ Branch 0 taken 1001 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 951 times.
✓ Branch 4 taken 905 times.
✓ Branch 5 taken 76 times.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 881 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 25 times.
1031 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
25987 {
25988 157 reset_pal_cycling();
25989 157 putscr(scrollbuf,0,0,tmpscr);
25990 157 putscrdoors(scrollbuf,0,0,tmpscr);
25991 157 walkdown2(COOLSCROLL);
25992 157 }
25993
2/2
✓ Branch 0 taken 852 times.
✓ Branch 1 taken 52 times.
906 else if(COOLSCROLL)
25994 {
25995 852 openscreen();
25996 852 }
25997 }
25998
25999 1678 show_subscreen_life=true;
26000 1678 show_subscreen_numbers=true;
26001
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1678 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 43 times.
1678 if (updatemusic || !musicnocut)
26002 {
26003 1721 playLevelMusic();
26004
1/2
✓ Branch 0 taken 1635 times.
✗ Branch 1 not taken.
1721 if (musicrevert)
26005 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26006 1635 }
26007 1678 currcset=DMaps[currdmap].color;
26008 1678 dointro();
26009 1678 set_respawn_point();
26010 1678 trySideviewLadder();
26011
26012
2/2
✓ Branch 0 taken 9810 times.
✓ Branch 1 taken 1678 times.
11488 for(int32_t i=0; i<6; i++)
26013 9810 visited[i]=-1;
26014
26015 1678 break;
26016 }
26017
26018 case wtSCROLL: // scrolling warp
26019 {
26020 841 int32_t c = DMaps[currdmap].color;
26021 841 scrolling_map = currmap;
26022 841 currmap = DMaps[wdmap].map;
26023 841 update_subscreens(wdmap);
26024
26025 841 dlevel = DMaps[wdmap].level;
26026 //check if Hero has the map for the new location before updating the subscreen. ? -Z
26027 //This works only in one direction, if Hero had a map, to not having one.
26028 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
26029 841 update_subscreens(wdmap);
26030
26031 /*if ( has_item(itype_map, dlevel) )
26032 {
26033 //Blank the map during an intra-dmap scrolling warp.
26034 dlevel = -1; //a hack for the minimap. This works!! -Z
26035 }*/
26036
26037 // fix the scrolling direction, if it was a tile or instant warp
26038
2/4
✓ Branch 0 taken 841 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 841 times.
841 if(type==0 || type>=3)
26039 {
26040 sdir = dir;
26041 }
26042
26043 841 scrollscr(sdir, wscr+DMaps[wdmap].xoff, wdmap);
26044 //dlevel = DMaps[wdmap].level; //Fix dlevel and draw the map (end hack). -Z
26045
26046 841 reset_hookshot();
26047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 841 times.
841 if(reposition_sword_postwarp)
26048 {
26049 weapon *swd=NULL;
26050 for(int32_t i=0; i<Lwpns.Count(); i++)
26051 {
26052 swd = (weapon*)Lwpns.spr(i);
26053
26054 if(swd->id == (attack==wSword ? wSword : wWand))
26055 {
26056 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26057 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26058 positionSword(swd,item_id);
26059 break;
26060 }
26061 }
26062 }
26063
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 752 times.
841 if(!intradmap)
26064 {
26065 752 homescr = currscr = wscr + DMaps[wdmap].xoff;
26066 752 init_dmap();
26067
26068 int32_t wrx,wry;
26069
26070
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 338 times.
752 if(get_qr(qr_NOARRIVALPOINT))
26071 {
26072 414 wrx=tmpscr->warpreturnx[0];
26073 414 wry=tmpscr->warpreturny[0];
26074 414 }
26075 else
26076 {
26077 338 wrx=tmpscr->warparrivalx;
26078 338 wry=tmpscr->warparrivaly;
26079 }
26080
26081
8/8
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 425 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 286 times.
✓ Branch 5 taken 466 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 274 times.
752 if(((wrx>0||wry>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))&&(!get_qr(qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
26082 {
26083
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 199 times.
274 if(dlevel)
26084 {
26085 75 lastentrance = currscr;
26086 75 }
26087 else
26088 {
26089 199 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
26090 }
26091
26092 274 lastentrance_dmap = wdmap;
26093 274 }
26094 752 }
26095
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 453 times.
841 if(DMaps[currdmap].color != c)
26096 {
26097 453 lighting(false, true);
26098 453 }
26099
26100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 841 times.
841 if (updatemusic)
26101 {
26102 841 playLevelMusic();
26103
1/2
✓ Branch 0 taken 841 times.
✗ Branch 1 not taken.
841 if (musicrevert)
26104 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26105 841 }
26106 841 currcset=DMaps[currdmap].color;
26107 841 dointro();
26108 }
26109 841 break;
26110
26111 case wtWHISTLE: // whistle warp
26112 {
26113 111 scrolling_map = currmap;
26114 111 currmap = DMaps[wdmap].map;
26115 111 scrollscr(index, wscr+DMaps[wdmap].xoff, wdmap);
26116 111 reset_hookshot();
26117 111 currdmap=wdmap;
26118 111 dlevel=DMaps[currdmap].level;
26119 111 lighting(false, true);
26120 111 init_dmap();
26121
26122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if (updatemusic)
26123 {
26124 111 playLevelMusic();
26125
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if (musicrevert)
26126 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26127 111 }
26128 111 currcset=DMaps[currdmap].color;
26129 111 dointro();
26130 111 action=inwind; FFCore.setHeroAction(inwind);
26131 int32_t wry;
26132
26133
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 83 times.
111 if(get_qr(qr_NOARRIVALPOINT))
26134 28 wry=tmpscr->warpreturny[0];
26135 83 else wry=tmpscr->warparrivaly;
26136
26137 int32_t wrx;
26138
26139
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 83 times.
111 if(get_qr(qr_NOARRIVALPOINT))
26140 28 wrx=tmpscr->warpreturnx[0];
26141 83 else wrx=tmpscr->warparrivalx;
26142
26143
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 111 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 111 times.
✓ Branch 10 taken 111 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 111 times.
✗ Branch 13 not taken.
222 Lwpns.add(new weapon((zfix)(index==left?240:index==right?0:wrx),(zfix)(index==down?0:index==up?160:wry),
26144
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 (zfix)0,wWind,1,0,index,whistleitem,getUID(),false,false,true,1));
26145 111 whirlwind=255;
26146 111 whistleitem=-1;
26147 }
26148 111 break;
26149
26150 case wtIWARP:
26151 case wtIWARPBLK:
26152 case wtIWARPOPEN:
26153 case wtIWARPZAP:
26154 case wtIWARPWAVE: // insta-warps
26155 {
26156 3588 bool old_192 = false;
26157
2/2
✓ Branch 0 taken 3544 times.
✓ Branch 1 taken 44 times.
3588 if (get_qr(qr_192b163_WARP))
26158 {
26159
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if ( wtype == wtIWARPWAVE )
26160 {
26161 wtype = wtIWARPWAVE;
26162 old_192 = true;
26163 }
26164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if ( old_192 )
26165 {
26166 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Wave Warp.\n %s\n", "Trying to redirect it into a Cancel Effect");
26167 didpit=false;
26168 update_subscreens();
26169 warp_sound = 0;
26170 is_warping = false;
26171 return false;
26172 }
26173 44 }
26174 //for determining whether to exit cave
26175 3588 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
26176 3588 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
26177 3588 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
26178
26179
8/8
✓ Branch 0 taken 3191 times.
✓ Branch 1 taken 397 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 3125 times.
✓ Branch 4 taken 3191 times.
✓ Branch 5 taken 66 times.
✓ Branch 6 taken 94 times.
✓ Branch 7 taken 3097 times.
6963 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
26180
8/8
✓ Branch 0 taken 3171 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 3105 times.
✓ Branch 4 taken 65 times.
✓ Branch 5 taken 3170 times.
✓ Branch 6 taken 3113 times.
✓ Branch 7 taken 57 times.
3191 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
26181
26182
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3201 times.
3998 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
26183 {
26184 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
26185 3201 bool wasswimming = (action == swimming);
26186 3201 int32_t olddiveclk = diveclk;
26187 3201 ALLOFF();
26188
26189
2/2
✓ Branch 0 taken 3165 times.
✓ Branch 1 taken 36 times.
3201 if(wasswimming)
26190 {
26191 36 Hero.SetSwim();
26192 36 diveclk = olddiveclk;
26193 36 }
26194
26195 3201 kill_sfx();
26196 3201 }
26197 //play sound
26198
2/2
✓ Branch 0 taken 3109 times.
✓ Branch 1 taken 95 times.
3204 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
26199
2/2
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 2615 times.
3204 if(wtype==wtIWARPZAP)
26200 {
26201 589 zapout();
26202 589 }
26203
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 2392 times.
2615 else if(wtype==wtIWARPWAVE)
26204 {
26205 //only draw Hero if he's not in a cave -DD
26206 223 wavyout(!cavewarp);
26207 223 }
26208
2/2
✓ Branch 0 taken 1479 times.
✓ Branch 1 taken 913 times.
2392 else if(wtype!=wtIWARP)
26209 {
26210
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 618 times.
913 bool b2 = COOLSCROLL&&cavewarp;
26211 913 blackscr(30,b2?false:true);
26212 913 }
26213
26214 3204 int32_t c = DMaps[currdmap].color;
26215 3204 bool changedlevel = false;
26216 3204 bool changeddmap = false;
26217
2/2
✓ Branch 0 taken 1497 times.
✓ Branch 1 taken 1707 times.
3204 if(currdmap != wdmap)
26218 {
26219 1707 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
26220 1707 changeddmap = true;
26221 1707 }
26222
2/2
✓ Branch 0 taken 2624 times.
✓ Branch 1 taken 580 times.
3204 if(dlevel != DMaps[wdmap].level)
26223 {
26224 580 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
26225 580 changedlevel = true;
26226 580 }
26227 3204 dlevel = DMaps[wdmap].level;
26228 3204 currdmap = wdmap;
26229
2/2
✓ Branch 0 taken 1497 times.
✓ Branch 1 taken 1707 times.
3204 if(changeddmap)
26230 {
26231 1707 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
26232 1707 }
26233
2/2
✓ Branch 0 taken 2624 times.
✓ Branch 1 taken 580 times.
3204 if(changedlevel)
26234 {
26235 580 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
26236 580 }
26237
26238 3204 currmap = DMaps[currdmap].map;
26239 3204 init_dmap();
26240 3204 update_subscreens(wdmap);
26241
26242 3204 ringcolor(false);
26243
26244
2/2
✓ Branch 0 taken 2340 times.
✓ Branch 1 taken 864 times.
3204 if(DMaps[currdmap].color != c)
26245 864 loadlvlpal(DMaps[currdmap].color);
26246
26247 3204 homescr = currscr = wscr + DMaps[currdmap].xoff;
26248
26249 3204 lightingInstant(); // Also sets naturaldark
26250
26251 3204 loadscr(0,currdmap,currscr,-1,overlay);
26252
26253 3204 x = tmpscr->warpreturnx[wrindex];
26254 3204 y = tmpscr->warpreturny[wrindex];
26255
26256
2/2
✓ Branch 0 taken 1943 times.
✓ Branch 1 taken 1261 times.
3204 if(didpit)
26257 {
26258 1261 didpit=false;
26259 1261 x=pitx;
26260 1261 y=pity;
26261 1261 }
26262
26263 3204 type1 = combobuf[MAPCOMBO(x,y-16)].type;
26264 3204 type2 = combobuf[MAPCOMBO(x,y)].type;
26265 3204 type3 = combobuf[MAPCOMBO(x,y+16)].type;
26266
26267
2/2
✓ Branch 0 taken 3127 times.
✓ Branch 1 taken 77 times.
3204 if(x==0) dir=right;
26268
26269
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 4 times.
3204 if(x==240) dir=left;
26270
26271
2/2
✓ Branch 0 taken 3161 times.
✓ Branch 1 taken 43 times.
3204 if(y==0) dir=down;
26272
26273
2/2
✓ Branch 0 taken 3136 times.
✓ Branch 1 taken 68 times.
3204 if(y==160) dir=up;
26274
26275 3204 markBmap(dir^1);
26276
26277 3204 int32_t checkwater = iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+(bigHitbox?8:12)); //iswaterex can be intensive, so let's avoid as many calls as we can.
26278
26279
10/16
✓ Branch 0 taken 3175 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 29 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 29 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 29 times.
✓ Branch 12 taken 29 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 29 times.
✓ Branch 15 taken 3175 times.
3233 if(checkwater && _walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) && current_item(itype_flippers) > 0 && current_item(itype_flippers) >= combobuf[checkwater].attribytes[0] && (!(combobuf[checkwater].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & item_flag3)))
26280 {
26281 29 hopclk=0xFF;
26282 29 SetSwim();
26283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if (!IsSideSwim()) attackclk = charging = spins = 0;
26284 29 }
26285 else
26286 {
26287 3175 action = none; FFCore.setHeroAction(none);
26288 }
26289 //preloaded freeform combos
26290 3204 ffscript_engine(true);
26291
26292 3204 putscr(scrollbuf,0,0,tmpscr);
26293 3204 putscrdoors(scrollbuf,0,0,tmpscr);
26294
26295
10/10
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 3126 times.
✓ Branch 4 taken 3192 times.
✓ Branch 5 taken 66 times.
✓ Branch 6 taken 79 times.
✓ Branch 7 taken 3113 times.
✓ Branch 8 taken 168 times.
✓ Branch 9 taken 247 times.
3204 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
26296 {
26297 312 reset_pal_cycling();
26298 312 putscr(scrollbuf,0,0,tmpscr);
26299 312 putscrdoors(scrollbuf,0,0,tmpscr);
26300 312 walkup(COOLSCROLL);
26301 312 }
26302
9/10
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 3105 times.
✓ Branch 4 taken 3189 times.
✓ Branch 5 taken 84 times.
✓ Branch 6 taken 75 times.
✓ Branch 7 taken 3114 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 75 times.
3360 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
26303 {
26304 339 reset_pal_cycling();
26305 339 putscr(scrollbuf,0,0,tmpscr);
26306 339 putscrdoors(scrollbuf,0,0,tmpscr);
26307 339 walkdown2(COOLSCROLL);
26308 339 }
26309
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 2602 times.
3189 else if(wtype==wtIWARPZAP)
26310 {
26311 587 zapin();
26312 587 }
26313
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 2382 times.
2602 else if(wtype==wtIWARPWAVE)
26314 {
26315 220 wavyin();
26316 220 }
26317
2/2
✓ Branch 0 taken 2248 times.
✓ Branch 1 taken 134 times.
2382 else if(wtype==wtIWARPOPEN)
26318 {
26319 134 openscreen();
26320 134 }
26321
1/2
✓ Branch 0 taken 3504 times.
✗ Branch 1 not taken.
3504 if(reposition_sword_postwarp)
26322 {
26323 weapon *swd=NULL;
26324 for(int32_t i=0; i<Lwpns.Count(); i++)
26325 {
26326 swd = (weapon*)Lwpns.spr(i);
26327
26328 if(swd->id == (attack==wSword ? wSword : wWand))
26329 {
26330 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26331 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26332 positionSword(swd,item_id);
26333 break;
26334 }
26335 }
26336 }
26337 3504 show_subscreen_life=true;
26338 3504 show_subscreen_numbers=true;
26339
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 3204 times.
3504 if (updatemusic)
26340 {
26341 3204 playLevelMusic();
26342
1/2
✓ Branch 0 taken 3204 times.
✗ Branch 1 not taken.
3204 if (musicrevert)
26343 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26344 3204 }
26345 3504 currcset=DMaps[currdmap].color;
26346 3504 dointro();
26347 3504 set_respawn_point();
26348 3504 trySideviewLadder();
26349 }
26350 3504 break;
26351
26352
26353 case wtNOWARP:
26354 {
26355 151 bool old_192 = false;
26356
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if (get_qr(qr_192b163_WARP))
26357 {
26358 wtype = wtIWARPWAVE;
26359 old_192 = true;
26360 }
26361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if ( old_192 )
26362 {
26363 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Cancel Warp.\n %s\n", "Trying to redirect it into a Wave Effect");
26364 //for determining whether to exit cave
26365 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
26366 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
26367 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
26368
26369 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
26370 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
26371
26372 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
26373 {
26374 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
26375 bool wasswimming = (action == swimming);
26376 int32_t olddiveclk = diveclk;
26377 ALLOFF();
26378
26379 if(wasswimming)
26380 {
26381 Hero.SetSwim();
26382 diveclk = olddiveclk;
26383 }
26384
26385 kill_sfx();
26386 }
26387 //play sound
26388 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
26389 if(wtype==wtIWARPZAP)
26390 {
26391 zapout();
26392 }
26393 else if(wtype==wtIWARPWAVE)
26394 {
26395 //only draw Hero if he's not in a cave -DD
26396 wavyout(!cavewarp);
26397 }
26398 else if(wtype!=wtIWARP)
26399 {
26400 bool b2 = COOLSCROLL&&cavewarp;
26401 blackscr(30,b2?false:true);
26402 }
26403
26404 int32_t c = DMaps[currdmap].color;
26405 bool changedlevel = false;
26406 bool changeddmap = false;
26407 if(currdmap != wdmap)
26408 {
26409 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
26410 changeddmap = true;
26411 }
26412 if(dlevel != DMaps[wdmap].level)
26413 {
26414 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
26415 changedlevel = true;
26416 }
26417 dlevel = DMaps[wdmap].level;
26418 currdmap = wdmap;
26419 if(changeddmap)
26420 {
26421 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
26422 }
26423 if(changedlevel)
26424 {
26425 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
26426 }
26427 currmap = DMaps[currdmap].map;
26428 init_dmap();
26429 update_subscreens(wdmap);
26430
26431 ringcolor(false);
26432
26433 if(DMaps[currdmap].color != c)
26434 loadlvlpal(DMaps[currdmap].color);
26435
26436 homescr = currscr = wscr + DMaps[currdmap].xoff;
26437
26438 lightingInstant(); // Also sets naturaldark
26439
26440 loadscr(0,currdmap,currscr,-1,overlay);
26441
26442 x = tmpscr->warpreturnx[wrindex];
26443 y = tmpscr->warpreturny[wrindex];
26444
26445 if(didpit)
26446 {
26447 didpit=false;
26448 x=pitx;
26449 y=pity;
26450 }
26451
26452 type1 = combobuf[MAPCOMBO(x,y-16)].type;
26453 type2 = combobuf[MAPCOMBO(x,y)].type;
26454 type3 = combobuf[MAPCOMBO(x,y+16)].type;
26455
26456 if(x==0) dir=right;
26457
26458 if(x==240) dir=left;
26459
26460 if(y==0) dir=down;
26461
26462 if(y==160) dir=up;
26463
26464 markBmap(dir^1);
26465
26466 if(iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+8) && _walkflag(x,y+8,0,SWITCHBLOCK_STATE) && current_item(itype_flippers))
26467 {
26468 hopclk=0xFF;
26469 SetSwim();
26470 if (!IsSideSwim()) attackclk = charging = spins = 0;
26471 }
26472 else
26473 {
26474 action = none;
26475 FFCore.setHeroAction(none);
26476 }
26477 //preloaded freeform combos
26478 ffscript_engine(true);
26479
26480 putscr(scrollbuf,0,0,tmpscr);
26481 putscrdoors(scrollbuf,0,0,tmpscr);
26482
26483 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
26484 {
26485 reset_pal_cycling();
26486 putscr(scrollbuf,0,0,tmpscr);
26487 putscrdoors(scrollbuf,0,0,tmpscr);
26488 walkup(COOLSCROLL);
26489 }
26490 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
26491 {
26492 reset_pal_cycling();
26493 putscr(scrollbuf,0,0,tmpscr);
26494 putscrdoors(scrollbuf,0,0,tmpscr);
26495 walkdown2(COOLSCROLL);
26496 }
26497 else if(wtype==wtIWARPZAP)
26498 {
26499 zapin();
26500 }
26501 else if(wtype==wtIWARPWAVE)
26502 {
26503 wavyin();
26504 }
26505 else if(wtype==wtIWARPOPEN)
26506 {
26507 openscreen();
26508 }
26509 if(reposition_sword_postwarp)
26510 {
26511 weapon *swd=NULL;
26512 for(int32_t i=0; i<Lwpns.Count(); i++)
26513 {
26514 swd = (weapon*)Lwpns.spr(i);
26515
26516 if(swd->id == (attack==wSword ? wSword : wWand))
26517 {
26518 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26519 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26520 positionSword(swd,item_id);
26521 break;
26522 }
26523 }
26524 }
26525 show_subscreen_life=true;
26526 show_subscreen_numbers=true;
26527 playLevelMusic();
26528 currcset=DMaps[currdmap].color;
26529 dointro();
26530 set_respawn_point();
26531 trySideviewLadder();
26532 break;
26533 }
26534 else
26535 {
26536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(reposition_sword_postwarp)
26537 {
26538 weapon *swd=NULL;
26539 for(int32_t i=0; i<Lwpns.Count(); i++)
26540 {
26541 swd = (weapon*)Lwpns.spr(i);
26542
26543 if(swd->id == (attack==wSword ? wSword : wWand))
26544 {
26545 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26546 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26547 positionSword(swd,item_id);
26548 break;
26549 }
26550 }
26551 }
26552 151 didpit=false;
26553 151 update_subscreens();
26554 151 warp_sound = 0;
26555 151 is_warping = false;
26556 151 return false;
26557 }
26558 }
26559 default:
26560 didpit=false;
26561 update_subscreens();
26562 warp_sound = 0;
26563 is_warping = false;
26564 if(reposition_sword_postwarp)
26565 {
26566 weapon *swd=NULL;
26567 for(int32_t i=0; i<Lwpns.Count(); i++)
26568 {
26569 swd = (weapon*)Lwpns.spr(i);
26570
26571 if(swd->id == (attack==wSword ? wSword : wWand))
26572 {
26573 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26574 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26575 positionSword(swd,item_id);
26576 break;
26577 }
26578 }
26579 }
26580 return false;
26581 }
26582
26583 // Stop Hero from drowning!
26584
5/6
✓ Branch 0 taken 6696 times.
✓ Branch 1 taken 343 times.
✓ Branch 2 taken 6696 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 343 times.
✓ Branch 5 taken 6353 times.
7039 if(action==drowning || action==lavadrowning || action==sidedrowning)
26585 {
26586 686 drownclk=0;
26587 686 drownclk=0;
26588 686 action=none; FFCore.setHeroAction(none);
26589 686 }
26590
26591 6353 int32_t checkwater = iswaterex(MAPCOMBO(x,y+(bigHitbox?8:12)), currmap, currscr, -1, x,y+(bigHitbox?8:12));
26592 // But keep him swimming if he ought to be!
26593 // Unless the water is too high levelled, in which case... well, he'll drown on transition probably anyways. -Dimi
26594
10/12
✓ Branch 0 taken 6682 times.
✓ Branch 1 taken 329 times.
✓ Branch 2 taken 6630 times.
✓ Branch 3 taken 52 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 52 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 52 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 49 times.
✓ Branch 10 taken 6972 times.
✓ Branch 11 taken 39 times.
6403 if(action!=rafting && checkwater && (_walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) || get_qr(qr_DROWN))
26595 //&& (current_item(itype_flippers) >= combobuf[checkwater].attribytes[0])
26596
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
52 && (action!=inwind))
26597 {
26598 39 hopclk=0xFF;
26599 39 SetSwim();
26600 39 }
26601
26602 7011 newscr_clk=frame;
26603 7011 activated_timed_warp=false;
26604 7011 eat_buttons();
26605
26606
2/2
✓ Branch 0 taken 1794 times.
✓ Branch 1 taken 5217 times.
7011 if(wtype!=wtIWARP)
26607 5217 attackclk=0;
26608
26609 7011 didstuff=0;
26610 7011 usecounts.clear();
26611 7011 map_bkgsfx(true);
26612 7011 loadside=dir^1;
26613 7011 whistleclk=-1;
26614
26615
3/4
✓ Branch 0 taken 6691 times.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 7011 times.
✗ Branch 3 not taken.
7011 if((z>0 || fakez>0) && isSideViewHero())
26616 {
26617 y-=z;
26618 y-=fakez;
26619 fakez=0;
26620 z=0;
26621 }
26622
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 6575 times.
7011 else if(!isSideViewHero())
26623 {
26624 6575 fall=0;
26625 6575 fakefall=0;
26626 6575 }
26627
26628 // If warping between top-down and sideview screens,
26629 // fix enemies that are carried over by Full Screen Warp
26630 7011 const bool tmpscr_is_sideview = isSideViewHero();
26631
26632
4/4
✓ Branch 0 taken 6577 times.
✓ Branch 1 taken 434 times.
✓ Branch 2 taken 6548 times.
✓ Branch 3 taken 29 times.
7011 if(!wasSideview && tmpscr_is_sideview)
26633 {
26634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 for(int32_t i=0; i<guys.Count(); i++)
26635 {
26636 if(guys.spr(i)->z > 0 || guys.spr(i)->fakez > 0)
26637 {
26638 guys.spr(i)->y -= guys.spr(i)->z;
26639 guys.spr(i)->y -= guys.spr(i)->fakez;
26640 guys.spr(i)->z = 0;
26641 guys.spr(i)->fakez = 0;
26642 }
26643
26644 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
26645 guys.spr(i)->yofs += 2;
26646 }
26647 29 }
26648
4/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 6863 times.
✓ Branch 2 taken 92 times.
✓ Branch 3 taken 27 times.
6982 else if(wasSideview && !tmpscr_is_sideview)
26649 {
26650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t i=0; i<guys.Count(); i++)
26651 {
26652 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
26653 guys.spr(i)->yofs -= 2;
26654 }
26655 27 }
26656
26657
6/6
✓ Branch 0 taken 4321 times.
✓ Branch 1 taken 2690 times.
✓ Branch 2 taken 428 times.
✓ Branch 3 taken 3893 times.
✓ Branch 4 taken 279 times.
✓ Branch 5 taken 177 times.
7011 if((DMaps[currdmap].type&dmfCONTINUE) || (currdmap==0&&get_qr(qr_DMAP_0_CONTINUE_BUG)))
26658 {
26659
2/2
✓ Branch 0 taken 1346 times.
✓ Branch 1 taken 1447 times.
2969 if(dlevel)
26660 {
26661 int32_t wrx,wry;
26662
26663
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 820 times.
1346 if(get_qr(qr_NOARRIVALPOINT))
26664 {
26665 526 wrx=tmpscr->warpreturnx[0];
26666 526 wry=tmpscr->warpreturny[0];
26667 526 }
26668 else
26669 {
26670 820 wrx=tmpscr->warparrivalx;
26671 820 wry=tmpscr->warparrivaly;
26672 }
26673
26674
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
1356 if((wtype == wtEXIT)
26675
10/10
✓ Branch 0 taken 954 times.
✓ Branch 1 taken 392 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 886 times.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 19 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 35 times.
✓ Branch 8 taken 10 times.
✓ Branch 9 taken 4 times.
1346 || (((wtype == wtSCROLL) && !intradmap) && ((wrx>0 || wry>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))))
26676 {
26677
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 392 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 28 times.
440 if(!(wtype==wtSCROLL)||!(get_qr(qr_NOSCROLLCONTINUE)))
26678 {
26679 412 game->set_continue_scrn(homescr);
26680 //Z_message("continue_scrn = %02X e/e\n",game->get_continue_scrn());
26681 412 }
26682
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 15 times.
28 else if(currdmap != game->get_continue_dmap())
26683 {
26684 15 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
26685 15 }
26686 440 }
26687 else
26688 {
26689
2/2
✓ Branch 0 taken 821 times.
✓ Branch 1 taken 85 times.
906 if(currdmap != game->get_continue_dmap())
26690 {
26691 85 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
26692 //Z_message("continue_scrn = %02X dlevel\n",game->get_continue_scrn());
26693 85 }
26694 }
26695 1346 }
26696 else
26697 {
26698 1447 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
26699 //Z_message("continue_scrn = %02X\n !dlevel\n",game->get_continue_scrn());
26700 }
26701
26702 2793 game->set_continue_dmap(currdmap);
26703 2793 lastentrance_dmap = currdmap;
26704 2793 lastentrance = game->get_continue_scrn();
26705 //Z_message("continue_map = %d\n",game->get_continue_dmap());
26706 2793 }
26707
26708
1/2
✓ Branch 0 taken 6863 times.
✗ Branch 1 not taken.
6863 if(tmpscr->flags4&fAUTOSAVE)
26709 {
26710 save_game(true,0);
26711 }
26712
26713
2/2
✓ Branch 0 taken 6718 times.
✓ Branch 1 taken 145 times.
6863 if(tmpscr->flags6&fCONTINUEHERE)
26714 {
26715 145 lastentrance_dmap = currdmap;
26716 145 lastentrance = homescr;
26717 145 }
26718
26719 6863 update_subscreens();
26720 6863 verifyBothWeapons();
26721
26722
2/2
✓ Branch 0 taken 6280 times.
✓ Branch 1 taken 583 times.
6863 if(wtype==wtCAVE)
26723 {
26724
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 154 times.
583 if(DMaps[currdmap].flags&dmfGUYCAVES)
26725 858 Z_eventlog("Entered %s containing %s.\n",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar",
26726 429 (char *)moduledata.roomtype_names[tmpscr[1].room]);
26727 else
26728 154 Z_eventlog("Entered %s.",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar");
26729 583 }
26730 12560 else Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
26731
2/2
✓ Branch 0 taken 489 times.
✓ Branch 1 taken 5791 times.
12071 wtype==wtPASS ? "Passageway" :
26732
2/2
✓ Branch 0 taken 1635 times.
✓ Branch 1 taken 4156 times.
9947 wtype==wtEXIT ? "Entrance/Exit" :
26733
2/2
✓ Branch 0 taken 841 times.
✓ Branch 1 taken 3315 times.
4156 wtype==wtSCROLL ? "Scrolling Warp" :
26734 3315 wtype==wtWHISTLE ? "Whistle Warp" :
26735 "Insta-Warp");
26736
26737 6863 eventlog_mapflags();
26738
1/2
✓ Branch 0 taken 6863 times.
✗ Branch 1 not taken.
6863 if(reposition_sword_postwarp)
26739 {
26740 weapon *swd=NULL;
26741 for(int32_t i=0; i<Lwpns.Count(); i++)
26742 {
26743 swd = (weapon*)Lwpns.spr(i);
26744
26745 if(swd->id == (attack==wSword ? wSword : wWand))
26746 {
26747 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26748 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26749 positionSword(swd,item_id);
26750 break;
26751 }
26752 }
26753 }
26754 6863 FFCore.clear_combo_scripts();
26755
4/4
✓ Branch 0 taken 2371 times.
✓ Branch 1 taken 4492 times.
✓ Branch 2 taken 2167 times.
✓ Branch 3 taken 204 times.
6863 if (!intradmap || get_qr(qr_WARPS_RESTART_DMAPSCRIPT))
26756 {
26757 6659 FFScript::deallocateAllScriptOwned(ScriptType::DMap, olddmap);
26758 6659 FFCore.initZScriptDMapScripts();
26759 6659 FFCore.initZScriptScriptedActiveSubscreen();
26760 6659 }
26761 6863 is_warping = false;
26762
2/2
✓ Branch 0 taken 6601 times.
✓ Branch 1 taken 262 times.
6863 if(!get_qr(qr_SCROLLWARP_NO_RESET_FRAME))
26763 262 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
26764 6863 return true;
26765 7014 }
26766
26767 384 void HeroClass::exitcave()
26768 {
26769 384 bool updatemusic = FFCore.can_dmap_change_music(currdmap);
26770 384 bool musicnocut = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_NOCUT;
26771
26772 384 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
26773 384 currscr=homescr;
26774 384 loadscr(0,currdmap,currscr,255,false); // bogus direction
26775 384 x = tmpscr->warpreturnx[0];
26776 384 y = tmpscr->warpreturny[0];
26777
26778
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(didpit)
26779 {
26780 didpit=false;
26781 x=pitx;
26782 y=pity;
26783 }
26784
26785
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 18 times.
384 if(x+y == 0)
26786 18 x = y = 80;
26787
26788 384 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
26789 384 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
26790 384 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
26791
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 335 times.
735 bool b = COOLSCROLL &&
26792
4/4
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 211 times.
335 ((type1==cCAVE) || (type1>=cCAVEB && type1<=cCAVED) ||
26793
4/4
✓ Branch 0 taken 213 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 208 times.
211 (type2==cCAVE) || (type2>=cCAVEB && type2<=cCAVED) ||
26794
4/4
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 190 times.
208 (type3==cCAVE2) || (type3>=cCAVE2B && type3<=cCAVE2D) ||
26795
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 5 times.
190 (type2==cCAVE2) || (type2>=cCAVE2B && type2<=cCAVE2D));
26796 400 ALLOFF();
26797 400 blackscr(30,b?false:true);
26798 400 ringcolor(false);
26799 400 loadlvlpal(DMaps[currdmap].color);
26800 400 lighting(false, true);
26801
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
400 if (updatemusic || !musicnocut)
26802 402 music_stop();
26803 408 kill_sfx();
26804 408 putscr(scrollbuf,0,0,tmpscr);
26805 408 putscrdoors(scrollbuf,0,0,tmpscr);
26806
26807
10/10
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 156 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 235 times.
✓ Branch 4 taken 237 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 232 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 7 times.
408 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
26808 {
26809 165 walkup(COOLSCROLL);
26810 165 }
26811
9/10
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 214 times.
✓ Branch 4 taken 219 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 214 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
239 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
26812 {
26813 22 walkdown2(COOLSCROLL);
26814 22 }
26815
26816 402 show_subscreen_life=true;
26817 402 show_subscreen_numbers=true;
26818
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 402 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
402 if (updatemusic || !musicnocut)
26819 402 playLevelMusic();
26820 402 currcset=DMaps[currdmap].color;
26821 402 dointro();
26822 402 newscr_clk=frame;
26823 402 activated_timed_warp=false;
26824 402 dir=down;
26825 402 set_respawn_point();
26826 402 eat_buttons();
26827 402 didstuff=0;
26828 402 usecounts.clear();
26829 402 map_bkgsfx(true);
26830 402 loadside=dir^1;
26831 402 }
26832
26833
26834 11093 void HeroClass::stepforward(int32_t steps, bool adjust)
26835 {
26836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11093 times.
11093 if ( FFCore.nostepforward ) return;
26837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11093 times.
11093 if ( FFCore.temp_no_stepforward ) { FFCore.temp_no_stepforward = 0; return; }
26838 11093 zfix tx=x; //temp x
26839 11093 zfix ty=y; //temp y
26840 11093 zfix tstep(0); //temp single step distance
26841 11093 zfix s(0); //calculated step distance for all steps
26842 11093 z3step=2;
26843 11093 int32_t sh=shiftdir;
26844 11093 shiftdir=-1;
26845
26846
2/2
✓ Branch 0 taken 189514 times.
✓ Branch 1 taken 11093 times.
200607 for(int32_t i=steps; i>0; --i)
26847 {
26848
2/2
✓ Branch 0 taken 499 times.
✓ Branch 1 taken 189015 times.
189514 if(diagonalMovement)
26849 {
26850
3/4
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 236 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 263 times.
499 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
26851 {
26852 236 tstep = 1.5;
26853 236 }
26854 else
26855 {
26856 263 tstep=z3step;
26857 263 z3step=(z3step%2)+1;
26858 }
26859 499 }
26860 else
26861 {
26862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189015 times.
189015 if(get_qr(qr_NEW_HERO_MOVEMENT))
26863 {
26864 tstep = 1.5;
26865 }
26866 else
26867 {
26868
2/2
✓ Branch 0 taken 105421 times.
✓ Branch 1 taken 83594 times.
189015 tstep=lsteps[int32_t((dir<left)?ty:tx)&7];
26869
26870
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 60091 times.
✓ Branch 2 taken 45330 times.
✓ Branch 3 taken 38591 times.
✓ Branch 4 taken 45003 times.
189015 switch(dir)
26871 {
26872 case up:
26873 60091 ty-=tstep;
26874 60091 break;
26875
26876 case down:
26877 45330 ty+=tstep;
26878 45330 break;
26879
26880 case left:
26881 38591 tx-=tstep;
26882 38591 break;
26883
26884 case right:
26885 45003 tx+=tstep;
26886 45003 break;
26887 }
26888 }
26889 }
26890
26891 189514 s+=tstep;
26892 189514 }
26893
26894 11093 z3step=2;
26895
26896 11093 x = x.getInt();
26897 11093 y = y.getInt();
26898
2/2
✓ Branch 0 taken 200374 times.
✓ Branch 1 taken 11090 times.
211464 while(s>=0)
26899 {
26900
2/2
✓ Branch 0 taken 501 times.
✓ Branch 1 taken 199873 times.
200374 if(diagonalMovement)
26901 {
26902
5/6
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 445 times.
✓ Branch 4 taken 56 times.
✗ Branch 5 not taken.
501 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
26903 {
26904 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
26905 {
26906 walkable = false;
26907 shiftdir = -1;
26908 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
26909 switch(tdir)
26910 {
26911 case left:
26912 --x;
26913 break;
26914 case right:
26915 ++x;
26916 break;
26917 case up:
26918 --y;
26919 break;
26920 case down:
26921 ++y;
26922 break;
26923 }
26924 }
26925 else
26926 {
26927 walkable=false;
26928 shiftdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
26929 moveOld2(dir, 150);
26930 }
26931 }
26932 else
26933 {
26934
3/4
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 257 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 244 times.
501 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
26935 {
26936 257 s-=1.5;
26937 257 }
26938 else
26939 {
26940 244 s-=z3step;
26941 }
26942 501 walkable=true;
26943 501 moveOld2(dir, 150);
26944 }
26945
26946 501 shiftdir=-1;
26947 501 }
26948 else
26949 {
26950
3/6
✓ Branch 0 taken 111662 times.
✓ Branch 1 taken 88211 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 199873 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
199873 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
26951 {
26952 walkable=false;
26953 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
26954 switch(tdir)
26955 {
26956 case left:
26957 --x;
26958 break;
26959 case right:
26960 ++x;
26961 break;
26962 case up:
26963 --y;
26964 break;
26965 case down:
26966 ++y;
26967 break;
26968 }
26969 }
26970 else
26971 {
26972
2/4
✓ Branch 0 taken 199873 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 199873 times.
199873 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
26973 {
26974 s-=1.5;
26975 }
26976
2/2
✓ Branch 0 taken 111662 times.
✓ Branch 1 taken 88211 times.
199873 else if(dir<left)
26977 {
26978 111662 s-=lsteps[y.getInt()&7];
26979 111662 }
26980 else
26981 {
26982 88211 s-=lsteps[x.getInt()&7];
26983 }
26984
26985 199873 moveOld2(dir, 150);
26986 }
26987 }
26988
26989
2/2
✓ Branch 0 taken 189284 times.
✓ Branch 1 taken 11090 times.
200374 if(s<0)
26990 {
26991 // Not quite sure how this is actually supposed to work.
26992 // There have to be two cases for each direction or Hero
26993 // either walks too far onto the screen or may get stuck
26994 // going through walk-through walls.
26995
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4000 times.
✓ Branch 2 taken 2454 times.
✓ Branch 3 taken 2115 times.
✓ Branch 4 taken 2521 times.
11090 switch(dir)
26996 {
26997 case up:
26998
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 3775 times.
4000 if(y<8) // Leaving the screen
26999 225 y+=s;
27000 else // Entering the screen
27001 3775 y-=s;
27002
27003 4000 break;
27004
27005 case down:
27006
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 2238 times.
2454 if(y>152)
27007 216 y-=s;
27008 else
27009 2238 y+=s;
27010
27011 2454 break;
27012
27013 case left:
27014
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 1940 times.
2115 if(x<8)
27015 175 x+=s;
27016 else
27017 1940 x-=s;
27018
27019 2115 break;
27020
27021 case right:
27022
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 2326 times.
2521 if(x>=232)
27023 195 x-=s;
27024 else
27025 2326 x+=s;
27026
27027 2521 break;
27028 }
27029 11090 }
27030
27031
27032 200374 clear_darkroom_bitmaps();
27033 200374 draw_screen(tmpscr);
27034
1/2
✓ Branch 0 taken 200374 times.
✗ Branch 1 not taken.
200374 if (canSideviewLadder()) setOnSideviewLadder(true);
27035 200374 advanceframe(true);
27036
27037
2/2
✓ Branch 0 taken 200371 times.
✓ Branch 1 taken 3 times.
200374 if(Quit)
27038 3 return;
27039 }
27040
4/4
✓ Branch 0 taken 8569 times.
✓ Branch 1 taken 2521 times.
✓ Branch 2 taken 2454 times.
✓ Branch 3 taken 6115 times.
11090 if(dir==right||dir==down)
27041 {
27042 4975 x=int32_t(x);
27043 4975 y=int32_t(y);
27044 4975 }
27045 else
27046 {
27047 6115 x = x.getInt();
27048 6115 y = y.getInt();
27049 }
27050 11090 set_respawn_point();
27051 11090 draw_screen(tmpscr);
27052 11090 eat_buttons();
27053 11090 shiftdir=sh;
27054 11093 }
27055
27056 456 void HeroClass::walkdown(bool opening) //entering cave
27057 {
27058
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 398 times.
456 if(opening)
27059 {
27060 398 close_black_opening(x+8, y+8+playing_field_offset, false);
27061 398 }
27062
27063 456 hclk=0;
27064 456 stop_item_sfx(itype_brang);
27065 456 sfx(WAV_STAIRS,pan(x.getInt()));
27066 456 clk=0;
27067 // Fix Hero's position to the grid
27068 456 y=y.getInt()&0xF0;
27069 456 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
27070 456 attack=wNone;
27071 456 attackid=-1;
27072 456 reset_swordcharge();
27073 456 climb_cover_x=x.getInt()&0xF0;
27074 456 climb_cover_y=(y.getInt()&0xF0)+16;
27075
27076 456 guys.clear();
27077 456 chainlinks.clear();
27078 456 Lwpns.clear();
27079 456 Ewpns.clear();
27080 456 items.clear();
27081
2/2
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 29184 times.
29640 for(int32_t i=0; i<64; i++)
27082 {
27083 29184 herostep();
27084
27085
2/4
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27086 hero_count=(hero_count+1)%16;
27087
27088
2/2
✓ Branch 0 taken 21888 times.
✓ Branch 1 taken 7296 times.
29184 if((i&3)==3)
27089 7296 ++y;
27090
27091 29184 draw_screen(tmpscr);
27092 29184 advanceframe(true);
27093
27094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(Quit)
27095 break;
27096 29184 }
27097
27098 456 action=none; FFCore.setHeroAction(none);
27099 456 }
27100
27101 120 void HeroClass::walkdown2(bool opening) //exiting cave 2
27102 {
27103 120 int32_t type = combobuf[MAPCOMBO(x,y)].type;
27104
27105
27106 // Fix Hero's position to the grid
27107 120 y=y.getInt()&0xF0;
27108
27109
3/6
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
27110 99 y -= 16;
27111
27112 120 climb_cover_x=x.getInt()&0xF0;
27113 120 climb_cover_y=y.getInt()&0xF0;
27114
27115 120 dir=down;
27116 120 z=fakez=fall=fakefall=0;
27117
27118
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 25 times.
120 if(opening)
27119 {
27120 25 open_black_opening(x+8, y+8+playing_field_offset+16, false);
27121 25 }
27122
27123 120 hclk=0;
27124 120 stop_item_sfx(itype_brang);
27125 120 sfx(WAV_STAIRS,pan(x.getInt()));
27126 120 clk=0;
27127 120 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
27128 120 attack=wNone;
27129 120 attackid=-1;
27130 120 reset_swordcharge();
27131
27132 120 guys.clear();
27133 120 chainlinks.clear();
27134 120 Lwpns.clear();
27135 120 Ewpns.clear();
27136 120 items.clear();
27137
27138
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 7680 times.
7800 for(int32_t i=0; i<64; i++)
27139 {
27140 7680 herostep();
27141
27142
2/4
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7680 times.
7680 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27143 hero_count=(hero_count+1)%16;
27144
27145
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 1920 times.
7680 if((i&3)==3)
27146 1920 ++y;
27147
27148 7680 draw_screen(tmpscr);
27149 7680 advanceframe(true);
27150
27151
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(Quit)
27152 break;
27153 7680 }
27154
27155
27156 120 action=none; FFCore.setHeroAction(none);
27157 120 }
27158
27159 379 void HeroClass::walkup(bool opening) //exiting cave
27160 {
27161 379 int32_t type = combobuf[MAPCOMBO(x,y)].type;
27162
27163
5/6
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 298 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
379 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
27164 55 y+=16;
27165
27166 // Fix Hero's position to the grid
27167 379 y=y.getInt()&0xF0;
27168 379 z=fakez=fall=fakefall=0;
27169
27170
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 331 times.
379 if(opening)
27171 {
27172 331 open_black_opening(x+8, y+8+playing_field_offset-16, false);
27173 331 }
27174
27175 379 hclk=0;
27176 379 stop_item_sfx(itype_brang);
27177 379 sfx(WAV_STAIRS,pan(x.getInt()));
27178 379 dir=down;
27179 379 clk=0;
27180 379 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
27181 379 attack=wNone;
27182 379 attackid=-1;
27183 379 reset_swordcharge();
27184 379 climb_cover_x=x.getInt()&0xF0;
27185 379 climb_cover_y=y.getInt()&0xF0;
27186
27187 379 guys.clear();
27188 379 chainlinks.clear();
27189 379 Lwpns.clear();
27190 379 Ewpns.clear();
27191 379 items.clear();
27192
27193
2/2
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 24256 times.
24635 for(int32_t i=0; i<64; i++)
27194 {
27195 24256 herostep();
27196
27197
2/4
✓ Branch 0 taken 24256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24256 times.
24256 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27198 hero_count=(hero_count+1)%16;
27199
27200
2/2
✓ Branch 0 taken 18192 times.
✓ Branch 1 taken 6064 times.
24256 if((i&3)==0)
27201 6064 --y;
27202
27203 24256 draw_screen(tmpscr);
27204 24256 advanceframe(true);
27205
27206
1/2
✓ Branch 0 taken 24256 times.
✗ Branch 1 not taken.
24256 if(Quit)
27207 break;
27208 24256 }
27209 379 map_bkgsfx(true);
27210 379 loadside=dir^1;
27211 379 action=none; FFCore.setHeroAction(none);
27212 379 }
27213
27214 421 void HeroClass::walkup2(bool opening) //entering cave2
27215 {
27216
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 325 times.
421 if(opening)
27217 {
27218 325 close_black_opening(x+8, y+8+playing_field_offset, false);
27219 325 }
27220
27221 421 hclk=0;
27222 421 stop_item_sfx(itype_brang);
27223 421 sfx(WAV_STAIRS,pan(x.getInt()));
27224 421 dir=up;
27225 421 clk=0;
27226 421 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
27227 421 attack=wNone;
27228 421 attackid=-1;
27229 421 reset_swordcharge();
27230 421 climb_cover_x=x.getInt()&0xF0;
27231 421 climb_cover_y=(y.getInt()&0xF0)-16;
27232
27233 421 guys.clear();
27234 421 chainlinks.clear();
27235 421 Lwpns.clear();
27236 421 Ewpns.clear();
27237 421 items.clear();
27238
27239
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 26944 times.
27365 for(int32_t i=0; i<64; i++)
27240 {
27241 26944 herostep();
27242
27243
2/4
✓ Branch 0 taken 26944 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26944 times.
26944 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27244 hero_count=(hero_count+1)%16;
27245
27246
2/2
✓ Branch 0 taken 20208 times.
✓ Branch 1 taken 6736 times.
26944 if((i&3)==0)
27247 6736 --y;
27248
27249 26944 draw_screen(tmpscr);
27250 26944 advanceframe(true);
27251
27252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26944 times.
26944 if(Quit)
27253 break;
27254 26944 }
27255 421 map_bkgsfx(true);
27256 421 loadside=dir^1;
27257 421 action=none; FFCore.setHeroAction(none);
27258 421 }
27259
27260 455 void HeroClass::stepout() // Step out of item cellars and passageways
27261 {
27262 455 bool updatemusic = FFCore.can_dmap_change_music(currdmap);
27263 455 bool musicnocut = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_NOCUT;
27264
27265 455 int32_t sc = specialcave; // This gets erased by ALLOFF()
27266 455 ALLOFF();
27267 455 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27268 455 kill_sfx();
27269 455 draw_screen(tmpscr,false);
27270 455 fade(sc>=GUYCAVE?10:11,true,false);
27271 455 blackscr(30,true);
27272 455 ringcolor(false);
27273
27274
4/4
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 271 times.
455 if(sc==PASSAGEWAY && abs(x-warpx)>16) // How did Hero leave the passageway?
27275 {
27276 271 currdmap=stepoutdmap;
27277 271 currmap=DMaps[currdmap].map;
27278 271 dlevel=DMaps[currdmap].level;
27279
27280 //we might have just left a passage, so be sure to update the CSet record -DD
27281 271 currcset=DMaps[currdmap].color;
27282
27283 271 init_dmap();
27284 271 homescr=stepoutscr;
27285 271 }
27286
27287 455 currscr=homescr;
27288 455 loadscr(0,currdmap,currscr,255,false); // bogus direction
27289 455 draw_screen(tmpscr,false);
27290
27291
4/4
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 444 times.
✓ Branch 3 taken 10 times.
455 if(get_qr(qr_NEW_DARKROOM) || !(tmpscr->flags&fDARK))
27292 {
27293 445 darkroom = naturaldark = false;
27294 445 fade(DMaps[currdmap].color,true,true);
27295 445 }
27296 else
27297 {
27298 10 darkroom = naturaldark = true;
27299
27300
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if(get_qr(qr_FADE))
27301 {
27302 8 interpolatedfade();
27303 8 }
27304 else
27305 {
27306 2 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
27307 }
27308 10 byte *si = colordata + CSET(DMaps[currdmap].color*pdLEVEL+poLEVEL)*3;
27309 10 si+=3*48;
27310
27311
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 10 times.
170 for(int32_t i=0; i<16; i++)
27312 {
27313 160 RAMpal[CSET(9)+i] = _RGB(si);
27314 160 tempgreypal[CSET(9)+i] = _RGB(si); //preserve monochrome
27315 160 si+=3;
27316 160 }
27317 }
27318
27319 455 x = tmpscr->warpreturnx[stepoutwr];
27320 455 y = tmpscr->warpreturny[stepoutwr];
27321
27322
1/2
✓ Branch 0 taken 455 times.
✗ Branch 1 not taken.
455 if(didpit)
27323 {
27324 didpit=false;
27325 x=pitx;
27326 y=pity;
27327 }
27328
27329
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 20 times.
455 if(x+y == 0)
27330 20 x = y = 80;
27331
27332 455 dir=down;
27333
27334 455 set_respawn_point();
27335
27336 // Let's use the 'exit cave' animation if we entered this cellar via a cave combo.
27337 455 int32_t type = combobuf[MAPCOMBO(tmpscr->warpreturnx[stepoutwr],tmpscr->warpreturny[stepoutwr])].type;
27338
27339
4/6
✓ Branch 0 taken 455 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 449 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
455 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
27340 {
27341 walkup(false);
27342 }
27343
4/6
✓ Branch 0 taken 455 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 449 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
455 else if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
27344 {
27345 walkdown2(false);
27346 }
27347
27348 455 newscr_clk=frame;
27349 455 activated_timed_warp=false;
27350 455 didstuff=0;
27351 455 usecounts.clear();
27352 455 eat_buttons();
27353 455 markBmap(-1);
27354 455 map_bkgsfx(true);
27355
27356
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 54 times.
455 if(!get_qr(qr_CAVEEXITNOSTOPMUSIC))
27357 {
27358
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if (updatemusic || !musicnocut)
27359 {
27360 54 music_stop();
27361 54 playLevelMusic();
27362 54 }
27363 54 }
27364
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 else if(get_qr(qr_SCREEN80_OWN_MUSIC))
27365 {
27366 if (updatemusic || !musicnocut)
27367 playLevelMusic();
27368 }
27369
27370 455 loadside=dir^1;
27371 455 }
27372
27373 30839 bool HeroClass::nextcombo_wf(int32_t d2)
27374 {
27375
6/8
✓ Branch 0 taken 30779 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 30340 times.
✓ Branch 3 taken 439 times.
✓ Branch 4 taken 30340 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 439 times.
✗ Branch 7 not taken.
30839 if(toogam || (action!=swimming && !IsSideSwim() && action != swimhit) || hopclk==0) //!DIMITODO: ...does swimming just let you ignore smart scrolling entirely!?
27376 30839 return false;
27377
27378 // assumes Hero is about to scroll screens
27379 int ns;
27380 if(auto scr = nextscr(d2,false))
27381 ns = *scr;
27382 else return false;
27383
27384 int32_t cx = x;
27385 int32_t cy = y;
27386
27387 switch(d2)
27388 {
27389 case up:
27390 cy=160;
27391 break;
27392
27393 case down:
27394 cy=0;
27395 break;
27396
27397 case left:
27398 cx=240;
27399 break;
27400
27401 case right:
27402 cx=0;
27403 break;
27404 }
27405
27406 // check lower half of combo
27407 cy += 8;
27408
27409 // from MAPCOMBO()
27410 int32_t cmb = (cy&0xF0)+(cx>>4);
27411
27412 if(cmb>175)
27413 return true;
27414
27415 const newcombo* c = &combobuf[TheMaps[ns].data[cmb]];
27416 bool dried = iswater_type(c->type) && DRIEDLAKE;
27417 bool swim = iswater_type(c->type) && (current_item(itype_flippers)) && !dried;
27418 int32_t b=1;
27419
27420 if(cx&8) b<<=2;
27421
27422 if(cy&8) b<<=1;
27423
27424 if((c->walk&b) && !dried && !swim)
27425 return true;
27426
27427 // next block (i.e. cnt==2)
27428 if(!(cx&8))
27429 {
27430 b<<=2;
27431 }
27432 else
27433 {
27434 c = &combobuf[TheMaps[ns].data[++cmb]];
27435 dried = iswater_type(c->type) && DRIEDLAKE;
27436 swim = iswater_type(c->type) && (current_item(itype_flippers)) && !dried;
27437 b=1;
27438
27439 if(cy&8)
27440 {
27441 b<<=1;
27442 }
27443 }
27444
27445 return (c->walk&b) ? !dried && !swim : false;
27446 30839 }
27447
27448 bool HeroClass::nextcombo_solid(int32_t d2)
27449 {
27450 if(toogam || currscr>=128)
27451 return false;
27452
27453 // assumes Hero is about to scroll screens
27454 int ns;
27455 if(auto scr = nextscr(d2,false))
27456 ns = *scr;
27457 else return false;
27458
27459 int32_t screen = (ns%MAPSCRS);
27460 int32_t map = (ns - screen) / MAPSCRS;
27461
27462 int32_t cx = x;
27463 int32_t cy = y;
27464
27465 switch(d2)
27466 {
27467 case up:
27468 cy=160;
27469 break;
27470
27471 case down:
27472 cy=0;
27473 break;
27474
27475 case left:
27476 cx=240;
27477 break;
27478
27479 case right:
27480 cx=0;
27481 break;
27482 }
27483
27484 if(d2==up) cy += 8;
27485
27486 if(d2==left||d2==right) cy+=bigHitbox?0:8;
27487
27488 int32_t initcx = cx;
27489 int32_t initcy = cy;
27490 // from MAPCOMBO()
27491
27492 for(int32_t i=0; i<=((bigHitbox&&!(d2==up||d2==down))?((initcy&7)?2:1):((initcy&7)?1:0)) && cy < 176; cy+=(cy%2)?7:8,i++)
27493 {
27494 cx = initcx;
27495 for(int32_t k=0; k<=(get_qr(qr_SMARTER_SMART_SCROLL)?((initcx&7)?2:1):0) && cx < 256; cx+=(cx%2)?7:8,k++)
27496 {
27497 int32_t cmb = (cy&0xF0)+(cx>>4);
27498
27499 if(cmb>175)
27500 {
27501 return true;
27502 }
27503
27504 newcombo const& c = combobuf[MAPCOMBO3(map, screen, -1,cx,cy, get_qr(qr_SMARTER_SMART_SCROLL))];
27505
27506 int32_t b=1;
27507
27508 if(cx&8) b<<=2;
27509
27510 if(cy&8) b<<=1;
27511
27512 //bool bridgedetected = false;
27513
27514 int32_t walk = c.walk;
27515 if (get_qr(qr_SMARTER_SMART_SCROLL))
27516 {
27517 for (int32_t m = 0; m <= 1; m++)
27518 {
27519 newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,cx,cy, true)];
27520 if (cmb.type == cBRIDGE)
27521 {
27522 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
27523 {
27524 int efflag = (cmb.walk & 0xF0)>>4;
27525 int newsolid = (cmb.walk & 0xF);
27526 walk = ((newsolid | walk) & (~efflag)) | (newsolid & efflag);
27527 }
27528 else walk &= cmb.walk;
27529 }
27530 else walk |= cmb.walk;
27531 }
27532 }
27533 /*
27534 if (bridgedetected)
27535 {
27536 continue;
27537 }*/
27538
27539 //bool swim = iswater_type(c.type) && (current_item(itype_flippers) || action==rafting);
27540 bool swim = iswaterex(MAPCOMBO3(map, screen, -1,cx,cy, get_qr(qr_SMARTER_SMART_SCROLL)), map, screen, -1, cx, cy, true, false, true) && (current_item(itype_flippers) || action==rafting);
27541
27542 if((walk&b) && !swim)
27543 {
27544 return true;
27545 }
27546 }
27547
27548 /*
27549 #if 0
27550
27551 //
27552 // next block (i.e. cnt==2)
27553 if(!(cx&8))
27554 {
27555 b<<=2;
27556 }
27557 else
27558 {
27559 c = combobuf[TheMaps[ns].data[++cmb]];
27560 dried = iswater_type(c.type) && DRIEDLAKE;
27561 //swim = iswater_type(c.type) && (current_item(itype_flippers));
27562 b=1;
27563
27564 if(cy&8)
27565 {
27566 b<<=1;
27567 }
27568 }
27569
27570 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
27571
27572 if((c.walk&b) && !dried && !swim)
27573 {
27574 return true;
27575 }
27576
27577 cx+=8;
27578
27579 if(cx&7)
27580 {
27581 if(!(cx&8))
27582 {
27583 b<<=2;
27584 }
27585 else
27586 {
27587 c = combobuf[TheMaps[ns].data[++cmb]];
27588 dried = iswater_type(c.type) && DRIEDLAKE;
27589 //swim = iswaterex(cmb, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
27590 b=1;
27591
27592 if(cy&8)
27593 {
27594 b<<=1;
27595 }
27596 }
27597
27598 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
27599
27600 if((c.walk&b) && !dried && !swim)
27601 return true;
27602 }
27603
27604 #endif
27605 */
27606 }
27607
27608 return false;
27609 }
27610
27611 14168568 void HeroClass::checkscroll()
27612 {
27613 //DO NOT scroll if Hero is vibrating due to Divine Escape effect -DD
27614
3/4
✓ Branch 0 taken 14164670 times.
✓ Branch 1 taken 3898 times.
✓ Branch 2 taken 14164670 times.
✗ Branch 3 not taken.
14168568 if(action == casting||action==sideswimcasting)
27615 3898 return;
27616
27617
2/2
✓ Branch 0 taken 8723 times.
✓ Branch 1 taken 14155947 times.
14164670 if(y<0)
27618 {
27619 8723 bool doit=true;
27620 8723 y=0;
27621
27622
5/6
✓ Branch 0 taken 8664 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 8664 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8668 times.
✓ Branch 5 taken 55 times.
8723 if((z > 0 || fakez > 0 || stomping) && get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
27623 55 doit = false;
27624
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8711 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
8723 if(lift_wpn && get_qr(qr_NO_SCROLL_WHILE_CARRYING))
27625 doit = false;
27626
27627
1/2
✓ Branch 0 taken 8723 times.
✗ Branch 1 not taken.
8723 if(nextcombo_wf(up))
27628 doit=false;
27629
27630
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 8723 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8723 if(get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling && !(tmpscr->flags2&wfUP))
27631 {
27632 if(nextcombo_solid(up))
27633 doit=false;
27634 }
27635
27636
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 8668 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55 times.
8723 if(doit || action==inwind)
27637 {
27638
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 8214 times.
8668 if(currscr>=128)
27639 {
27640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(specialcave >= GUYCAVE)
27641 exitcave();
27642 454 else stepout();
27643 454 }
27644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8214 times.
8214 else if(action==inwind)
27645 {
27646 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
27647 {
27648 action=none; FFCore.setHeroAction(none);
27649 restart_level();
27650 }
27651 else
27652 {
27653 dowarp(2,up);
27654 }
27655 }
27656
3/6
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 7832 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 382 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8214 else if(tmpscr->flags2&wfUP && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
27657 {
27658 382 sdir=up;
27659 382 dowarp(1,(tmpscr->sidewarpindex)&3);
27660 382 }
27661
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 7781 times.
7832 else if(!edge_of_dmap(up))
27662 {
27663 7781 scrolling_map = currmap;
27664 7781 scrollscr(up);
27665
27666
1/2
✓ Branch 0 taken 7781 times.
✗ Branch 1 not taken.
7781 if(tmpscr->flags4&fAUTOSAVE)
27667 {
27668 save_game(true,0);
27669 }
27670
27671
2/2
✓ Branch 0 taken 7456 times.
✓ Branch 1 taken 325 times.
7781 if(tmpscr->flags6&fCONTINUEHERE)
27672 {
27673 325 lastentrance_dmap = currdmap;
27674 325 lastentrance = homescr;
27675 325 }
27676 7781 }
27677 8668 }
27678 8723 }
27679
27680
2/2
✓ Branch 0 taken 7083 times.
✓ Branch 1 taken 14157587 times.
14164670 if(y>160)
27681 {
27682 7083 bool doit=true;
27683 7083 y=160;
27684
27685
5/6
✓ Branch 0 taken 6999 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 6999 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7002 times.
✓ Branch 5 taken 81 times.
7083 if((z > 0 || fakez > 0 || stomping) && get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
27686 81 doit = false;
27687
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7076 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7083 if(lift_wpn && get_qr(qr_NO_SCROLL_WHILE_CARRYING))
27688 doit = false;
27689
27690
1/2
✓ Branch 0 taken 7083 times.
✗ Branch 1 not taken.
7083 if(nextcombo_wf(down))
27691 doit=false;
27692
27693
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 7083 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
7083 if(get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfDOWN))
27694 {
27695 if(nextcombo_solid(down))
27696 doit=false;
27697 }
27698
27699
3/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 7002 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
7083 if(doit || action==inwind)
27700 {
27701
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 6656 times.
7002 if(currscr>=128)
27702 {
27703
2/2
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 1 times.
346 if(specialcave >= GUYCAVE)
27704 345 exitcave();
27705 1 else stepout();
27706 346 }
27707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
6656 else if(action==inwind)
27708 {
27709 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
27710 {
27711 action=none; FFCore.setHeroAction(none);
27712 restart_level();
27713 }
27714 else
27715 {
27716 dowarp(2,down);
27717 }
27718 }
27719
3/6
✓ Branch 0 taken 950 times.
✓ Branch 1 taken 5706 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 950 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6656 else if(tmpscr->flags2&wfDOWN && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
27720 {
27721 950 sdir=down;
27722 950 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
27723 950 }
27724
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 5668 times.
5706 else if(!edge_of_dmap(down))
27725 {
27726 5668 scrolling_map = currmap;
27727 5668 scrollscr(down);
27728
27729
1/2
✓ Branch 0 taken 5668 times.
✗ Branch 1 not taken.
5668 if(tmpscr->flags4&fAUTOSAVE)
27730 {
27731 save_game(true,0);
27732 }
27733
27734
2/2
✓ Branch 0 taken 5554 times.
✓ Branch 1 taken 114 times.
5668 if(tmpscr->flags6&fCONTINUEHERE)
27735 {
27736 114 lastentrance_dmap = currdmap;
27737 114 lastentrance = homescr;
27738 114 }
27739 5668 }
27740 7002 }
27741 7083 }
27742
27743
2/2
✓ Branch 0 taken 6643 times.
✓ Branch 1 taken 14158027 times.
14164670 if(x<0)
27744 {
27745 6643 bool doit=true;
27746 6643 x=0;
27747
27748
4/6
✓ Branch 0 taken 6640 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 6640 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6643 times.
✗ Branch 5 not taken.
6643 if((z > 0 || fakez > 0 || stomping) && get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
27749 doit = false;
27750
3/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 6567 times.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
6643 if(lift_wpn && get_qr(qr_NO_SCROLL_WHILE_CARRYING))
27751 doit = false;
27752
27753
1/2
✓ Branch 0 taken 6643 times.
✗ Branch 1 not taken.
6643 if(nextcombo_wf(left))
27754 doit=false;
27755
27756
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6643 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
6643 if(get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfLEFT))
27757 {
27758 if(nextcombo_solid(left))
27759 doit=false;
27760 }
27761
27762
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6643 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6643 if(doit || action==inwind)
27763 {
27764
1/2
✓ Branch 0 taken 6643 times.
✗ Branch 1 not taken.
6643 if(currscr>=128)
27765 {
27766 if(specialcave >= GUYCAVE)
27767 exitcave();
27768 else stepout();
27769 }
27770
27771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6643 times.
6643 if(action==inwind)
27772 {
27773 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
27774 {
27775 action=none; FFCore.setHeroAction(none);
27776 restart_level();
27777 }
27778 else
27779 {
27780 dowarp(2,left);
27781 }
27782 }
27783
3/6
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 6375 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 268 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6643 else if(tmpscr->flags2&wfLEFT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
27784 {
27785 268 sdir=left;
27786 268 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
27787 268 }
27788
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 6216 times.
6375 else if(!edge_of_dmap(left))
27789 {
27790 6216 scrolling_map = currmap;
27791 6216 scrollscr(left);
27792
27793
1/2
✓ Branch 0 taken 6216 times.
✗ Branch 1 not taken.
6216 if(tmpscr->flags4&fAUTOSAVE)
27794 {
27795 save_game(true,0);
27796 }
27797
27798
2/2
✓ Branch 0 taken 6178 times.
✓ Branch 1 taken 38 times.
6216 if(tmpscr->flags6&fCONTINUEHERE)
27799 {
27800 38 lastentrance_dmap = currdmap;
27801 38 lastentrance = homescr;
27802 38 }
27803 6216 }
27804 6643 }
27805 6643 }
27806
27807
2/2
✓ Branch 0 taken 7484 times.
✓ Branch 1 taken 14157186 times.
14164670 if(x>240)
27808 {
27809 7484 bool doit=true;
27810 7484 x=240;
27811
27812
5/6
✓ Branch 0 taken 7439 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 7439 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7439 times.
✓ Branch 5 taken 45 times.
7484 if((z > 0 || fakez > 0 || stomping) && get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
27813 45 doit = false;
27814
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7473 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
7484 if(lift_wpn && get_qr(qr_NO_SCROLL_WHILE_CARRYING))
27815 doit = false;
27816
27817
1/2
✓ Branch 0 taken 7484 times.
✗ Branch 1 not taken.
7484 if(nextcombo_wf(right))
27818 doit=false;
27819
27820
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 7484 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
7484 if(get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfRIGHT))
27821 {
27822 if(nextcombo_solid(right))
27823 doit=false;
27824 }
27825
27826
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 7439 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
7484 if(doit || action==inwind)
27827 {
27828
1/2
✓ Branch 0 taken 7439 times.
✗ Branch 1 not taken.
7439 if(currscr>=128)
27829 {
27830 if(specialcave >= GUYCAVE)
27831 exitcave();
27832 else stepout();
27833 }
27834
27835
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 7327 times.
7439 if(action==inwind)
27836 {
27837
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 111 times.
112 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
27838 {
27839 1 action=none; FFCore.setHeroAction(none);
27840 1 restart_level();
27841 1 }
27842 else
27843 {
27844 111 dowarp(2,right);
27845 }
27846 112 }
27847
3/6
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 7040 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 287 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7327 else if(tmpscr->flags2&wfRIGHT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
27848 {
27849 287 sdir=right;
27850 287 dowarp(1,(tmpscr->sidewarpindex>>6)&3);
27851 287 }
27852
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 6928 times.
7040 else if(!edge_of_dmap(right))
27853 {
27854 6928 scrolling_map = currmap;
27855 6928 scrollscr(right);
27856
27857
1/2
✓ Branch 0 taken 6928 times.
✗ Branch 1 not taken.
6928 if(tmpscr->flags4&fAUTOSAVE)
27858 {
27859 save_game(true,0);
27860 }
27861
27862
2/2
✓ Branch 0 taken 6876 times.
✓ Branch 1 taken 52 times.
6928 if(tmpscr->flags6&fCONTINUEHERE)
27863 {
27864 52 lastentrance_dmap = currdmap;
27865 52 lastentrance = homescr;
27866 52 }
27867 6928 }
27868 7439 }
27869 7484 }
27870 14168568 }
27871
27872 // assumes current direction is in lastdir[3]
27873 // compares directions with scr->path and scr->exitdir
27874 79980 bool HeroClass::checkmaze(mapscr *scr, bool sound)
27875 {
27876
2/2
✓ Branch 0 taken 79482 times.
✓ Branch 1 taken 498 times.
79980 if(!(scr->flags&fMAZE))
27877 79482 return true;
27878
27879
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 444 times.
498 if(lastdir[3]==scr->exitdir)
27880 54 return true;
27881
27882
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 66 times.
764 for(int32_t i=0; i<4; i++)
27883
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 378 times.
698 if(lastdir[i]!=scr->path[i])
27884 378 return false;
27885
27886
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 33 times.
66 if(sound)
27887 33 sfx(scr->secretsfx);
27888
27889 66 return true;
27890 79980 }
27891
27892 53387 bool HeroClass::edge_of_dmap(int32_t side)
27893 {
27894
2/2
✓ Branch 0 taken 53168 times.
✓ Branch 1 taken 219 times.
53387 if(checkmaze(tmpscr,false)==false)
27895 219 return false;
27896
27897 // needs fixin'
27898 // should check dmap style
27899
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 15478 times.
✓ Branch 2 taken 11316 times.
✓ Branch 3 taken 12499 times.
✓ Branch 4 taken 13875 times.
53168 switch(side)
27900 {
27901 case up:
27902 15478 return currscr<16;
27903
27904 case down:
27905 11316 return currscr>=112;
27906
27907 case left:
27908
2/2
✓ Branch 0 taken 12341 times.
✓ Branch 1 taken 158 times.
12499 if((currscr&15)==0)
27909 158 return true;
27910
27911
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 5236 times.
12341 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
27912 // if(dlevel)
27913 7105 return (((currscr&15)-DMaps[currdmap].xoff)<=0);
27914
27915 5236 break;
27916
27917 case right:
27918
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 13763 times.
13875 if((currscr&15)==15)
27919 112 return true;
27920
27921
2/2
✓ Branch 0 taken 7813 times.
✓ Branch 1 taken 5950 times.
13763 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
27922 // if(dlevel)
27923 7813 return (((currscr&15)-DMaps[currdmap].xoff)>=7);
27924
27925 5950 break;
27926 }
27927
27928 11186 return false;
27929 53387 }
27930
27931 454 bool HeroClass::lookaheadraftflag(int32_t d2)
27932 {
27933 // Helper for scrollscr that gets next combo on next screen.
27934 // Can use destscr for scrolling warps,
27935 // but assumes currmap is correct.
27936
27937 454 int32_t cx = x;
27938 454 int32_t cy = y + 8;
27939
27940 454 bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27941 454 bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27942 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
27943 //Applying this here, too. -Z
27944
27945
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 100 times.
✓ Branch 4 taken 115 times.
454 switch(d2)
27946 {
27947 case up:
27948 128 cy=160;
27949 128 break;
27950
27951 case down:
27952 111 cy=0;
27953 111 break;
27954
27955 case left:
27956 100 cx=240;
27957 100 break;
27958
27959 case right:
27960 115 cx=0;
27961 115 break;
27962 }
27963
27964 454 int32_t combo = (cy&0xF0)+(cx>>4);
27965
27966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(combo>175)
27967 return 0;
27968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 return ( isRaftFlag(combobuf[tmpscr[0].data[combo]].flag) || isRaftFlag(tmpscr[0].sflag[combo]));
27969
27970 454 }
27971 27555 int32_t HeroClass::lookahead(int32_t d2) // Helper for scrollscr that gets next combo on next screen.
27972 {
27973 // Can use destscr for scrolling warps,
27974 // but assumes currmap is correct.
27975
27976 27555 int32_t cx = vbound(x,0_zf,240_zf); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
27977 27555 int32_t cy = vbound(y + 8,0_zf,160_zf);
27978 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27979 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27980 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
27981
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8006 times.
✓ Branch 2 taken 5875 times.
✓ Branch 3 taken 6418 times.
✓ Branch 4 taken 7256 times.
27555 switch(d2)
27982 {
27983 case up:
27984 8006 cy=160;
27985 8006 break;
27986
27987 case down:
27988 5875 cy=0;
27989 5875 break;
27990
27991 case left:
27992 6418 cx=240;
27993 6418 break;
27994
27995 case right:
27996 7256 cx=0;
27997 7256 break;
27998 }
27999
28000 27555 int32_t combo = (cy&0xF0)+(cx>>4);
28001
28002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27555 times.
27555 if(combo>175)
28003 return 0;
28004
28005 27555 return tmpscr[0].data[combo]; // entire combo code
28006 27555 }
28007
28008 27555 int32_t HeroClass::lookaheadflag(int32_t d2)
28009 {
28010 // Helper for scrollscr that gets next combo on next screen.
28011 // Can use destscr for scrolling warps,
28012 // but assumes currmap is correct.
28013
28014 27555 int32_t cx = vbound(x,0_zf,240_zf);
28015 27555 int32_t cy = vbound(y + 8,0_zf,160_zf);
28016
28017 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
28018 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
28019 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
28020 //Applying this here, too. -Z
28021
28022
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8006 times.
✓ Branch 2 taken 5875 times.
✓ Branch 3 taken 6418 times.
✓ Branch 4 taken 7256 times.
27555 switch(d2)
28023 {
28024 case up:
28025 8006 cy=160;
28026 8006 break;
28027
28028 case down:
28029 5875 cy=0;
28030 5875 break;
28031
28032 case left:
28033 6418 cx=240;
28034 6418 break;
28035
28036 case right:
28037 7256 cx=0;
28038 7256 break;
28039 }
28040
28041 27555 int32_t combo = (cy&0xF0)+(cx>>4);
28042
28043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27555 times.
27555 if(combo>175)
28044 return 0;
28045
28046
2/2
✓ Branch 0 taken 26692 times.
✓ Branch 1 taken 863 times.
27555 if(!tmpscr[0].sflag[combo])
28047 {
28048 26692 return combobuf[tmpscr[0].data[combo]].flag; // flag
28049 }
28050
28051 863 return tmpscr[0].sflag[combo]; // flag
28052 27555 }
28053
28054 3215722 void HeroClass::run_scrolling_script_int(bool waitdraw)
28055 {
28056
2/2
✓ Branch 0 taken 1607023 times.
✓ Branch 1 taken 1608699 times.
3215722 if(waitdraw)
28057 {
28058
3/4
✓ Branch 0 taken 1607023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1129664 times.
✓ Branch 3 taken 477359 times.
1607023 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
28059 {
28060 477359 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
28061 477359 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
28062 477359 }
28063 1607023 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
28064
5/6
✓ Branch 0 taken 1606366 times.
✓ Branch 1 taken 657 times.
✓ Branch 2 taken 35905 times.
✓ Branch 3 taken 1570461 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 35905 times.
1607023 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28065 {
28066 35905 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
28067 35905 FFCore.waitdraw(ScriptType::Player) = false;
28068 35905 }
28069 1607023 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
28070
4/6
✓ Branch 0 taken 1607023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1989 times.
✓ Branch 3 taken 1605034 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1989 times.
1607023 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28071 {
28072 1989 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
28073 1989 FFCore.waitdraw(ScriptType::DMap) = false;
28074 1989 }
28075 1607023 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
28076
2/6
✓ Branch 0 taken 1607023 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1607023 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1607023 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28077 {
28078 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
28079 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
28080 }
28081 1607023 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
28082
5/10
✓ Branch 0 taken 1606433 times.
✓ Branch 1 taken 590 times.
✓ Branch 2 taken 2161 times.
✓ Branch 3 taken 1604272 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2161 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1607023 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && FFCore.waitdraw(ScriptType::Screen, currscr) && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28083 {
28084 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script, currscr);
28085 FFCore.waitdraw(ScriptType::Screen, currscr) = 0;
28086 }
28087 1607023 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
28088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1607023 times.
1607023 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
28089 {
28090 1607023 FFCore.itemScriptEngineOnWaitdraw();
28091 1607023 }
28092 1607023 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
28093 1607023 }
28094 else
28095 {
28096
7/8
✓ Branch 0 taken 1608109 times.
✓ Branch 1 taken 590 times.
✓ Branch 2 taken 2200 times.
✓ Branch 3 taken 1605909 times.
✓ Branch 4 taken 987 times.
✓ Branch 5 taken 1213 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 987 times.
1608699 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28097 {
28098 987 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script, currscr);
28099 987 }
28100 1608699 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS);
28101
3/4
✓ Branch 0 taken 1608699 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 529689 times.
✓ Branch 3 taken 1079010 times.
1608699 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.doscript(ScriptType::Global, GLOBAL_SCRIPT_GAME))
28102 {
28103 529689 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
28104 529689 }
28105 1608699 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_ACTIVE);
28106
6/6
✓ Branch 0 taken 1608041 times.
✓ Branch 1 taken 658 times.
✓ Branch 2 taken 1545217 times.
✓ Branch 3 taken 62824 times.
✓ Branch 4 taken 1508839 times.
✓ Branch 5 taken 36378 times.
1608699 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.doscript(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
28107 {
28108 36378 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
28109 36378 }
28110 1608699 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_ACTIVE);
28111
5/6
✓ Branch 0 taken 1608699 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1607843 times.
✓ Branch 3 taken 856 times.
✓ Branch 4 taken 1508839 times.
✓ Branch 5 taken 99004 times.
1608699 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28112 {
28113 99004 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
28114 99004 }
28115 1608699 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE);
28116
4/6
✓ Branch 0 taken 1608699 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1608699 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1508839 times.
✓ Branch 5 taken 99860 times.
1608699 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28117 {
28118 99860 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
28119 99860 }
28120 1608699 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN);
28121 1608699 bool old = get_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING);
28122
3/4
✓ Branch 0 taken 1608699 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56094 times.
✓ Branch 3 taken 1552605 times.
1608699 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && old)
28123 1552605 FFCore.itemScriptEngine();
28124 1608699 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_OLD_ITEMDATA_SCRIPT);
28125
3/4
✓ Branch 0 taken 1608699 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1552605 times.
✓ Branch 3 taken 56094 times.
1608699 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && !old)
28126 56094 FFCore.itemScriptEngine();
28127 }
28128 3215722 }
28129 //Bit of a messy kludge to give the correct Hero->X/Hero->Y in the script
28130 3215722 void HeroClass::run_scrolling_script(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
28131 {
28132 // For rafting (and possibly other esoteric things)
28133 // Hero's action should remain unchanged while scrolling,
28134 // but for the sake of scripts, here's an eye-watering kludge.
28135 3215722 actiontype lastaction = action;
28136 3215722 action=scrolling; FFCore.setHeroAction(scrolling);
28137
2/2
✓ Branch 0 taken 1607023 times.
✓ Branch 1 taken 1608699 times.
3215722 if(waitdraw)
28138 {
28139 1607023 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
28140 1607023 }
28141 else
28142 {
28143 1608699 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
28144 }
28145 3215722 zfix storex = x, storey = y;
28146
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 808338 times.
✓ Branch 2 taken 581193 times.
✓ Branch 3 taken 854462 times.
✓ Branch 4 taken 971729 times.
3215722 switch(scrolldir)
28147 {
28148 case up:
28149
2/2
✓ Branch 0 taken 660412 times.
✓ Branch 1 taken 147926 times.
808338 if(y < 160) y = 176;
28150
4/4
✓ Branch 0 taken 123955 times.
✓ Branch 1 taken 23971 times.
✓ Branch 2 taken 52647 times.
✓ Branch 3 taken 71308 times.
147926 else if(cx > 0 && !end_frames) y = sy + 156;
28151 76618 else y = 160;
28152
28153 808338 break;
28154
28155 case down:
28156
2/2
✓ Branch 0 taken 473201 times.
✓ Branch 1 taken 107992 times.
581193 if(y > 0) y = -16;
28157
4/4
✓ Branch 0 taken 90181 times.
✓ Branch 1 taken 17811 times.
✓ Branch 2 taken 39760 times.
✓ Branch 3 taken 50421 times.
107992 else if(cx > 0 && !end_frames) y = sy - 172;
28158 57571 else y = 0;
28159
28160 581193 break;
28161
28162 case left:
28163
2/2
✓ Branch 0 taken 783189 times.
✓ Branch 1 taken 71273 times.
854462 if(x < 240) x = 256;
28164
2/2
✓ Branch 0 taken 58027 times.
✓ Branch 1 taken 13246 times.
71273 else if(cx > 0) x = sx + 236;
28165 13246 else x = 240;
28166
28167 854462 break;
28168
28169 case right:
28170
2/2
✓ Branch 0 taken 890890 times.
✓ Branch 1 taken 80839 times.
971729 if(x > 0) x = -16;
28171
2/2
✓ Branch 0 taken 65887 times.
✓ Branch 1 taken 14952 times.
80839 else if(cx > 0) x = sx - 252;
28172 14952 else x = 0;
28173
28174 971729 break;
28175 }
28176 3215722 run_scrolling_script_int(waitdraw);
28177
28178 3215722 x = storex, y = storey;
28179
28180 3215722 action=lastaction; FFCore.setHeroAction(lastaction);
28181 3215722 }
28182
28183 //Has solving the maze enabled a side warp?
28184 //Only used just before scrolling screens
28185 // Note: since scrollscr() calls this, and dowarp() calls scrollscr(),
28186 // return true to abort the topmost scrollscr() call. -L
28187 27555 bool HeroClass::maze_enabled_sizewarp(int32_t scrolldir)
28188 {
28189
2/2
✓ Branch 0 taken 82665 times.
✓ Branch 1 taken 27555 times.
110220 for(int32_t i = 0; i < 3; i++) lastdir[i] = lastdir[i+1];
28190
28191
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 27333 times.
27555 lastdir[3] = tmpscr->flags&fMAZE ? scrolldir : 0xFF;
28192
28193
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27555 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27555 if(tmpscr->flags8&fMAZEvSIDEWARP && tmpscr->flags&fMAZE && scrolldir != tmpscr->exitdir)
28194 {
28195 switch(scrolldir)
28196 {
28197 case up:
28198 if(tmpscr->flags2&wfUP && checkmaze(tmpscr,true))
28199 {
28200 lastdir[3] = 0xFF;
28201 sdir=up;
28202 dowarp(1,(tmpscr->sidewarpindex)&3);
28203 return true;
28204 }
28205
28206 break;
28207
28208 case down:
28209 if(tmpscr->flags2&wfDOWN && checkmaze(tmpscr,true))
28210 {
28211 lastdir[3] = 0xFF;
28212 sdir=down;
28213 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
28214 return true;
28215 }
28216
28217 break;
28218
28219 case left:
28220 if(tmpscr->flags2&wfLEFT && checkmaze(tmpscr,true))
28221 {
28222 lastdir[3] = 0xFF;
28223 sdir=left;
28224 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
28225 return true;
28226 }
28227
28228 break;
28229
28230 case right:
28231 if(tmpscr->flags2&wfRIGHT && checkmaze(tmpscr,true))
28232 {
28233 lastdir[3] = 0xFF;
28234 sdir=right;
28235 dowarp(1,(tmpscr->sidewarpindex)&3);
28236 return true;
28237 }
28238
28239 break;
28240 }
28241 }
28242
28243 27555 return false;
28244 27555 }
28245
28246 27555 int32_t HeroClass::get_scroll_step(int32_t scrolldir)
28247 {
28248 // For side-scrollers, where the relative speed of 'fast' scrolling is a bit slow.
28249
2/2
✓ Branch 0 taken 2578 times.
✓ Branch 1 taken 24977 times.
27555 if(get_qr(qr_VERYFASTSCROLLING))
28250 2578 return 16;
28251
28252
2/2
✓ Branch 0 taken 23521 times.
✓ Branch 1 taken 1456 times.
24977 if(get_qr(qr_SMOOTHVERTICALSCROLLING) != 0)
28253 {
28254
2/2
✓ Branch 0 taken 15535 times.
✓ Branch 1 taken 7986 times.
23521 return (isdungeon() && !get_qr(qr_FASTDNGN)) ? 2 : 4;
28255 }
28256 else
28257 {
28258
4/4
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 485 times.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 776 times.
1456 if(scrolldir == up || scrolldir == down)
28259 {
28260 680 return 8;
28261 }
28262 else
28263 {
28264
2/2
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 435 times.
776 return (isdungeon() && !get_qr(qr_FASTDNGN)) ? 2 : 4;
28265 }
28266 }
28267 27555 }
28268
28269 27555 int32_t HeroClass::get_scroll_delay(int32_t scrolldir)
28270 {
28271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27555 times.
27555 if(get_qr(qr_NOSCROLL))
28272 return 0;
28273
28274
4/4
✓ Branch 0 taken 24977 times.
✓ Branch 1 taken 2578 times.
✓ Branch 2 taken 23521 times.
✓ Branch 3 taken 1456 times.
27555 if( (get_qr(qr_VERYFASTSCROLLING) != 0) ||
28275 24977 (get_qr(qr_SMOOTHVERTICALSCROLLING) != 0) )
28276 {
28277 26099 return 1;
28278 }
28279 else
28280 {
28281
4/4
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 485 times.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 776 times.
1456 if(scrolldir == up || scrolldir == down)
28282 {
28283
2/2
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 321 times.
680 return (isdungeon() && !get_qr(qr_FASTDNGN)) ? 4 : 2;
28284 }
28285 else
28286 {
28287 776 return 1;
28288 }
28289 }
28290 27555 }
28291
28292 249483 void HeroClass::calc_darkroom_hero(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
28293 {
28294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249483 times.
249483 if(!get_qr(qr_NEW_DARKROOM)) return;
28295 249483 int32_t lampid = current_item_id(itype_lantern);
28296
2/2
✓ Branch 0 taken 248624 times.
✓ Branch 1 taken 859 times.
249483 if(lampid < 0) return;
28297
2/4
✓ Branch 0 taken 248624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248624 times.
✗ Branch 3 not taken.
248624 if(!(checkbunny(lampid) && checkmagiccost(lampid,lamp_paid)))
28298 {
28299 lamp_paid = false;
28300 return;
28301 }
28302 248624 lamp_paid = true;
28303 248624 paymagiccost(lampid,false,true);
28304 248624 int32_t hx1 = x.getInt() - x1 + 8;
28305 248624 int32_t hy1 = y.getInt() - y1 + 8;
28306 248624 int32_t hx2 = x.getInt() - x2 + 8;
28307 248624 int32_t hy2 = y.getInt() - y2 + 8;
28308
28309 248624 itemdata& lamp = itemsbuf[lampid];
28310 248624 handle_lighting(hx1,hy1,lamp.misc1,lamp.misc2,dir,darkscr_bmp_curscr);
28311 248624 handle_lighting(hx2,hy2,lamp.misc1,lamp.misc2,dir,darkscr_bmp_scrollscr);
28312 249483 }
28313
28314 27555 void HeroClass::scrollscr(int32_t scrolldir, int32_t destscr, int32_t destdmap)
28315 {
28316
2/4
✓ Branch 0 taken 27555 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27555 times.
27555 if(action==freeze||action==sideswimfreeze)
28317 {
28318 return;
28319 }
28320
28321 27555 bool overlay = false;
28322
28323
2/4
✓ Branch 0 taken 27555 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27555 times.
27555 if(scrolldir >= 0 && scrolldir <= 3)
28324 {
28325 27555 overlay = get_bit(&tmpscr[(currscr < 128) ? 0 : 1].sidewarpoverlayflags, scrolldir) ? true : false;
28326 27555 }
28327
28328 27555 bool updatemusic = FFCore.can_dmap_change_music(destdmap);
28329 27555 bool musicrevert = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_REVERT;
28330
28331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27555 times.
27555 if(maze_enabled_sizewarp(scrolldir)) // dowarp() was called
28332 return;
28333
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27555 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
27555 bool isForceFaceUp = getOnSideviewLadder() && canSideviewLadder() &&
28334 !(jumping<0 || fall!=0 || fakefall!=0) && get_qr(qr_SIDEVIEWLADDER_FACEUP);
28335 27555 bool room_was_dark = room_is_dark;
28336
1/2
✓ Branch 0 taken 27555 times.
✗ Branch 1 not taken.
27555 if(isForceFaceUp) dir = up;
28337 27555 kill_enemy_sfx();
28338 27555 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
28339 27555 screenscrolling = true;
28340 27555 FFCore.ScrollingData[SCROLLDATA_DIR] = scrolldir;
28341
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8006 times.
✓ Branch 2 taken 5875 times.
✓ Branch 3 taken 6418 times.
✓ Branch 4 taken 7256 times.
27555 switch(scrolldir)
28342 {
28343 case up:
28344 8006 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
28345 8006 FFCore.ScrollingData[SCROLLDATA_NY] = -176;
28346 8006 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
28347 8006 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
28348 8006 break;
28349 case down:
28350 5875 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
28351 5875 FFCore.ScrollingData[SCROLLDATA_NY] = 176;
28352 5875 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
28353 5875 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
28354 5875 break;
28355 case left:
28356 6418 FFCore.ScrollingData[SCROLLDATA_NX] = -256;
28357 6418 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
28358 6418 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
28359 6418 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
28360 6418 break;
28361 case right:
28362 7256 FFCore.ScrollingData[SCROLLDATA_NX] = 256;
28363 7256 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
28364 7256 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
28365 7256 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
28366 7256 break;
28367 }
28368 27555 FFCore.clear_combo_scripts();
28369 27555 tmpscr[1] = tmpscr[0];
28370
28371
2/2
✓ Branch 0 taken 165330 times.
✓ Branch 1 taken 27555 times.
192885 for(int32_t i = 0; i < 6; i++)
28372 {
28373 165330 tmpscr3[i] = tmpscr2[i];
28374 165330 }
28375
28376 27555 conveyclk = 2;
28377
28378 27555 mapscr *newscr = &tmpscr[0];
28379 27555 mapscr *oldscr = &tmpscr[1];
28380
28381 //scroll x, scroll y, old screen x, old screen y, new screen x, new screen y
28382 27555 int32_t sx = 0, sy = 0, tx = 0, ty = 0, tx2 = 0, ty2 = 0;
28383 27555 int32_t cx = 0;
28384 27555 int32_t step = get_scroll_step(scrolldir);
28385 27555 int32_t delay = get_scroll_delay(scrolldir);
28386 27555 bool end_frames = false;
28387
28388 27555 int32_t scx = get_qr(qr_FASTDNGN) ? 30 : 0;
28389
2/2
✓ Branch 0 taken 24977 times.
✓ Branch 1 taken 2578 times.
27555 if(get_qr(qr_VERYFASTSCROLLING)) //just a minor adjustment.
28390 2578 scx = 32; //for sideview very fast screolling.
28391
28392
28393 27555 int32_t lastattackclk = attackclk, lastspins = spins, lastcharging = charging; bool lasttapping = tapping;
28394 27555 actiontype lastaction = action;
28395 27555 ALLOFF(false, false);
28396 // for now, restore Hero's previous action
28397
2/2
✓ Branch 0 taken 25835 times.
✓ Branch 1 taken 1720 times.
27555 if(!get_qr(qr_SCROLLING_KILLS_CHARGE))
28398 1720 charging = lastcharging;
28399
2/2
✓ Branch 0 taken 9117 times.
✓ Branch 1 taken 18438 times.
27555 if (replay_version_check(0, 28))
28400 {
28401 // nargads_trail_crystal_crusades replay tests need this.
28402
2/2
✓ Branch 0 taken 18222 times.
✓ Branch 1 taken 216 times.
18438 if(!get_qr(qr_SCROLLING_KILLS_CHARGE)) attackclk = lastattackclk;
28403 18438 spins = lastspins; charging = lastcharging; tapping = lasttapping;
28404 18438 }
28405
28406 27555 action=lastaction; FFCore.setHeroAction(lastaction);
28407
28408 27555 lstep = (lstep + 6) % 12;
28409 27555 cx = scx;
28410 27555 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
28411
3/4
✓ Branch 0 taken 27555 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18187 times.
✓ Branch 3 taken 9368 times.
27555 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
28412 {
28413 9368 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
28414 9368 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
28415 9368 }
28416 27555 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
28417
5/6
✓ Branch 0 taken 27544 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 883 times.
✓ Branch 3 taken 26661 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 883 times.
27555 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28418 {
28419 883 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
28420 883 FFCore.waitdraw(ScriptType::Player) = false;
28421 883 }
28422 27555 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
28423
4/6
✓ Branch 0 taken 27555 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 27519 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
27555 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28424 {
28425 36 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
28426 36 FFCore.waitdraw(ScriptType::DMap) = false;
28427 36 }
28428 27555 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
28429
2/6
✓ Branch 0 taken 27555 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27555 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27555 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28430 {
28431 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
28432 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
28433 }
28434 27555 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
28435
7/8
✓ Branch 0 taken 27545 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 27525 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 11 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
27555 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && FFCore.waitdraw(ScriptType::Screen, currscr) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28436 {
28437 9 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script, currscr);
28438 9 FFCore.waitdraw(ScriptType::Screen, currscr) = 0;
28439 9 }
28440 27555 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
28441
28442 27555 word c = tmpscr->numFFC();
28443
2/2
✓ Branch 0 taken 824999 times.
✓ Branch 1 taken 27555 times.
852554 for ( word q = 0; q < c; ++q )
28444 {
28445
1/2
✓ Branch 0 taken 824999 times.
✗ Branch 1 not taken.
824999 if (FFCore.waitdraw(ScriptType::FFC, q))
28446 {
28447 if(tmpscr->ffcs[q].script != 0)
28448 {
28449 ZScriptVersion::RunScript(ScriptType::FFC, tmpscr->ffcs[q].script, q);
28450 FFCore.waitdraw(ScriptType::FFC, q) = false;
28451 }
28452 }
28453 824999 }
28454 27555 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFC_WAITDRAW);
28455 27555 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_COMBO_WAITDRAW);
28456 //Waitdraw for item scripts.
28457 27555 FFCore.itemScriptEngineOnWaitdraw();
28458 27555 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
28459 27555 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_NPC_WAITDRAW);
28460
28461 //Sprite scripts on Waitdraw
28462 27555 FFCore.eweaponScriptEngineOnWaitdraw();
28463 27555 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_EWPN_WAITDRAW);
28464 27555 FFCore.itemSpriteScriptEngineOnWaitdraw();
28465 27555 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEMSPRITE_WAITDRAW);
28466
28467 //This is no longer a do-while, as the first iteration is now slightly different. -Em
28468 27555 draw_screen(tmpscr,true,true);
28469
28470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27555 times.
27555 if(cx == scx)
28471 27555 rehydratelake(false);
28472
28473 27555 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
28474 27555 advanceframe(true);
28475
28476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27555 times.
27555 if(Quit)
28477 {
28478 screenscrolling = false;
28479 return;
28480 }
28481
28482 27555 ++cx;
28483
2/2
✓ Branch 0 taken 138617 times.
✓ Branch 1 taken 27555 times.
166172 while(cx < 32)
28484 {
28485
1/2
✓ Branch 0 taken 138617 times.
✗ Branch 1 not taken.
138617 if(isForceFaceUp) dir = up;
28486
2/2
✓ Branch 0 taken 579 times.
✓ Branch 1 taken 138038 times.
138617 if(get_qr(qr_FIXSCRIPTSDURINGSCROLLING))
28487 {
28488 579 script_drawing_commands.Clear();
28489 579 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
28490 579 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
28491 579 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
28492 579 }
28493 138038 else FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
28494 138617 draw_screen(tmpscr,true,true);
28495
28496
1/2
✓ Branch 0 taken 138617 times.
✗ Branch 1 not taken.
138617 if(cx == scx)
28497 rehydratelake(false);
28498
28499 138617 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
28500 138617 advanceframe(true);
28501
28502
1/2
✓ Branch 0 taken 138617 times.
✗ Branch 1 not taken.
138617 if(Quit)
28503 {
28504 screenscrolling = false;
28505 return;
28506 }
28507
28508 138617 ++cx;
28509 }
28510 27555 script_drawing_commands.Clear();
28511 27555 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
28512
28513
28514 //clear Hero's last hits
28515 //for ( int32_t q = 0; q < 4; q++ ) sethitHeroUID(q, 0);
28516
28517
3/4
✓ Branch 0 taken 12040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6835 times.
✓ Branch 3 taken 8680 times.
27555 switch(DMaps[currdmap].type&dmfTYPE)
28518 {
28519 case dmDNGN:
28520
2/2
✓ Branch 0 taken 8673 times.
✓ Branch 1 taken 7 times.
8680 if(!get_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING))
28521 {
28522 7 markBmap(scrolldir);
28523 7 }
28524 8680 break;
28525 case dmOVERW: case dmBSOVERW:
28526
2/2
✓ Branch 0 taken 11799 times.
✓ Branch 1 taken 241 times.
12040 if(get_qr(qr_NO_OVERWORLD_MAP_CHARTING))
28527 11799 break;
28528 [[fallthrough]];
28529 case dmCAVE:
28530 7076 markBmap(scrolldir);
28531 7076 break;
28532 }
28533
28534
1/2
✓ Branch 0 taken 27555 times.
✗ Branch 1 not taken.
27555 if(fixed_door)
28535 {
28536 unsetmapflag(mSECRET);
28537 fixed_door = false;
28538 }
28539
28540 27555 playing_field_offset = original_playing_field_offset;
28541
28542 27555 scrolling_scr = currscr;
28543
28544
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8006 times.
✓ Branch 2 taken 5875 times.
✓ Branch 3 taken 6418 times.
✓ Branch 4 taken 7256 times.
27555 switch(scrolldir)
28545 {
28546 case up:
28547 {
28548
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 7781 times.
8006 if(destscr != -1)
28549 225 currscr = destscr;
28550
3/4
✓ Branch 0 taken 7719 times.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7719 times.
7781 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
28551 7719 currscr -= 16;
28552
28553 8006 loadscr(0,destdmap,currscr,scrolldir,overlay);
28554 8006 blit(scrollbuf,scrollbuf,0,0,0,176,256,176);
28555 8006 putscr(scrollbuf,0,0,newscr);
28556 8006 putscrdoors(scrollbuf,0,0,newscr);
28557 8006 sy=176;
28558
28559
2/2
✓ Branch 0 taken 7521 times.
✓ Branch 1 taken 485 times.
8006 if(get_qr(qr_SMOOTHVERTICALSCROLLING) == 0)
28560 485 sy+=3;
28561
28562 8006 cx=176/step;
28563 8006 FFCore.clear_combo_scripts();
28564 }
28565 8006 break;
28566
28567 case down:
28568 {
28569
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 5668 times.
5875 if(destscr != -1)
28570 207 currscr = destscr;
28571
3/4
✓ Branch 0 taken 5646 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5646 times.
5668 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
28572 5646 currscr += 16;
28573
28574 5875 loadscr(0,destdmap,currscr,scrolldir,overlay);
28575 5875 putscr(scrollbuf,0,176,newscr);
28576 5875 putscrdoors(scrollbuf,0,176,newscr);
28577 5875 sy = 0;
28578
28579
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 195 times.
5875 if(get_qr(qr_SMOOTHVERTICALSCROLLING) == 0)
28580 195 sy+=3;
28581
28582 5875 cx = 176 / step;
28583 5875 FFCore.clear_combo_scripts();
28584 }
28585 5875 break;
28586
28587 case left:
28588 {
28589
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 6216 times.
6418 if(destscr!=-1)
28590 202 currscr = destscr;
28591
3/4
✓ Branch 0 taken 6183 times.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6183 times.
6216 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
28592 6183 --currscr;
28593
28594 6418 loadscr(0,destdmap,currscr,scrolldir,overlay);
28595 6418 blit(scrollbuf,scrollbuf,0,0,256,0,256,176);
28596 6418 putscr(scrollbuf,0,0,newscr);
28597 6418 putscrdoors(scrollbuf,0,0,newscr);
28598 6418 sx = 256;
28599 6418 cx = 256 / step;
28600 6418 FFCore.clear_combo_scripts();
28601 }
28602 6418 break;
28603
28604 case right:
28605 {
28606
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 6928 times.
7256 if(destscr != -1)
28607 328 currscr = destscr;
28608
3/4
✓ Branch 0 taken 6886 times.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6886 times.
6928 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
28609 6886 ++currscr;
28610
28611 7256 loadscr(0,destdmap,currscr,scrolldir,overlay);
28612 7256 putscr(scrollbuf,256,0,newscr);
28613 7256 putscrdoors(scrollbuf,256,0,tmpscr);
28614 7256 sx = 0;
28615 7256 cx = 256 / step;
28616 7256 FFCore.clear_combo_scripts();
28617 }
28618 7256 break;
28619 }
28620
28621 // change Hero's state if entering water
28622 27555 int32_t ahead = lookahead(scrolldir);
28623 27555 int32_t aheadflag = lookaheadflag(scrolldir);
28624 27555 int32_t lookaheadx = vbound(x+8,0_zf,240_zf); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
28625 27555 int32_t lookaheady = vbound(y + (bigHitbox?8:12),0_zf,160_zf);
28626 27555 int32_t wateraheadx1 = vbound(x+4,0_zf,240_zf);
28627 27555 int32_t wateraheadx2 = vbound(x+11,0_zf,240_zf);
28628 27555 int32_t wateraheady1 = vbound(y+9,0_zf,160_zf);
28629 27555 int32_t wateraheady2 = vbound(y+15,0_zf,160_zf);
28630 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
28631 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
28632 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
28633
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8006 times.
✓ Branch 2 taken 5875 times.
✓ Branch 3 taken 6418 times.
✓ Branch 4 taken 7256 times.
27555 switch(scrolldir)
28634 {
28635 case up:
28636 8006 lookaheady=160;
28637 8006 wateraheady1=160;
28638 8006 wateraheady2=160;
28639 8006 break;
28640
28641 case down:
28642 5875 lookaheady=0;
28643 5875 wateraheady1=0;
28644 5875 wateraheady2=0;
28645 5875 break;
28646
28647 case left:
28648 6418 lookaheadx=240;
28649 6418 wateraheadx1=240;
28650 6418 wateraheadx2=240;
28651 6418 break;
28652
28653 case right:
28654 7256 lookaheadx=0;
28655 7256 wateraheadx1=0;
28656 7256 wateraheadx2=0;
28657 7256 break;
28658 }
28659
28660 27555 bool nowinwater = false;
28661
28662
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 27444 times.
27555 if(lastaction != inwind)
28663 {
28664
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 26990 times.
27444 if(lastaction == rafting ) //&& isRaftFlag(aheadflag))
28665 {
28666
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 438 times.
454 if (lookaheadraftflag(scrolldir))
28667 {
28668 438 action=rafting; FFCore.setHeroAction(rafting);
28669 438 raftclk=0;
28670 438 }
28671 454 }
28672
6/6
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 26610 times.
✓ Branch 2 taken 373 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 348 times.
26990 else if(iswaterex(ahead, currmap, currscr, -1, wateraheadx1,wateraheady1) && iswaterex(ahead, currmap, currscr, -1, wateraheadx2,wateraheady2) && (current_item(itype_flippers)))
28673 {
28674
9/16
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 328 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 20 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 20 times.
348 if(lastaction==swimming || lastaction == sideswimming || lastaction == sideswimattacking || lastaction == sideswimhit || lastaction == swimhit || lastaction == sideswimcasting || lastaction == sidewaterhold1 || lastaction == sidewaterhold2)
28675 {
28676 328 SetSwim();
28677 328 hopclk = 0xFF;
28678 328 nowinwater = true;
28679 328 }
28680 else
28681 {
28682 20 action=hopping; FFCore.setHeroAction(hopping);
28683 20 hopclk = 2;
28684 20 nowinwater = true;
28685 }
28686 348 }
28687
4/4
✓ Branch 0 taken 26596 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 26610 times.
26642 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
28688 {
28689 32 action = lastaction; FFCore.setHeroAction(lastaction);
28690 32 }
28691 else
28692 {
28693 26610 action=none; FFCore.setHeroAction(none);
28694 }
28695 27444 }
28696
28697
1/2
✓ Branch 0 taken 27555 times.
✗ Branch 1 not taken.
27555 isForceFaceUp = isForceFaceUp && canSideviewLadderRemote(lookaheadx,lookaheady);
28698
28699 // The naturaldark state can be read/set by an FFC script before
28700 // fade() or lighting() is called.
28701
2/2
✓ Branch 0 taken 2055 times.
✓ Branch 1 taken 25500 times.
27555 naturaldark = !get_qr(qr_NEW_DARKROOM) && (newscr->flags & fDARK);
28702
28703
2/2
✓ Branch 0 taken 27253 times.
✓ Branch 1 taken 302 times.
27555 if(newscr->oceansfx != oldscr->oceansfx) adjust_sfx(oldscr->oceansfx, 128, false);
28704
28705
2/2
✓ Branch 0 taken 27100 times.
✓ Branch 1 taken 455 times.
27555 if(newscr->bosssfx != oldscr->bosssfx) adjust_sfx(oldscr->bosssfx, 128, false);
28706 //Preloaded ffc scripts
28707 27555 homescr=currscr;
28708 27555 auto olddmap = currdmap;
28709
2/2
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 26593 times.
27555 auto newdmap = (destdmap >= 0) ? destdmap : currdmap;
28710
28711 27555 currdmap = newdmap;
28712 27555 ffscript_engine(true);
28713 27555 currdmap = olddmap;
28714
28715 // There are two occasions when scrolling must be darkened:
28716 // 1) When scrolling into a dark room.
28717 // 2) When scrolling between DMaps of different colours.
28718
4/4
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 26593 times.
✓ Branch 2 taken 461 times.
✓ Branch 3 taken 501 times.
27555 if(destdmap != -1 && DMaps[destdmap].color != currcset)
28719 {
28720
1/2
✓ Branch 0 taken 501 times.
✗ Branch 1 not taken.
501 fade((specialcave > 0) ? (specialcave >= GUYCAVE) ? 10 : 11 : currcset, true, false);
28721 501 darkroom = true;
28722 501 }
28723
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 26800 times.
27054 else if(!darkroom)
28724 26800 lighting(false, false); // NES behaviour: fade to dark before scrolling
28725
28726
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 27101 times.
27555 if(action != rafting) // Is this supposed to be here?!
28727
28728 27101 cx++; //This was the easiest way to re-arrange the loop so drawing is in the middle
28729
28730 27555 cx *= delay; //so we can have drawing re-done every frame,
28731 //previously it was for(0 to delay) advanceframes at end of loop
28732 27555 int32_t no_move = 0;
28733
28734 27555 currdmap = newdmap;
28735
4/4
✓ Branch 0 taken 27552 times.
✓ Branch 1 taken 1606447 times.
✓ Branch 2 taken 1606447 times.
✓ Branch 3 taken 27552 times.
1633999 for(word i = 0; cx >= 0 && delay != 0; i++, cx--) //Go!
28736 {
28737
2/2
✓ Branch 0 taken 1447071 times.
✓ Branch 1 taken 159376 times.
1606447 if (replay_version_check(0, 3))
28738 {
28739 159376 replay_poll();
28740 159376 }
28741
2/2
✓ Branch 0 taken 1606444 times.
✓ Branch 1 taken 3 times.
1606447 if(Quit)
28742 {
28743 3 screenscrolling = false;
28744 3 return;
28745 }
28746
28747
28748 1606444 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false);
28749
28750
2/2
✓ Branch 0 taken 1491505 times.
✓ Branch 1 taken 114939 times.
1606444 if(no_move > 0)
28751 114939 no_move--;
28752
28753 //Don't want to move things on the first or last iteration, or between delays
28754
6/6
✓ Branch 0 taken 1578889 times.
✓ Branch 1 taken 27555 times.
✓ Branch 2 taken 1538136 times.
✓ Branch 3 taken 40753 times.
✓ Branch 4 taken 33025 times.
✓ Branch 5 taken 1505111 times.
1606444 if(i == 0 || cx == 0 || cx % delay != 0)
28755 101333 no_move++;
28756
28757
4/4
✓ Branch 0 taken 1202636 times.
✓ Branch 1 taken 403808 times.
✓ Branch 2 taken 290276 times.
✓ Branch 3 taken 912360 times.
1606444 if(scrolldir == up || scrolldir == down)
28758 {
28759
2/2
✓ Branch 0 taken 644063 times.
✓ Branch 1 taken 50021 times.
694084 if(!get_qr(qr_SMOOTHVERTICALSCROLLING))
28760 {
28761 //Add a few extra frames if on the second loop and cool scrolling is not set
28762
2/2
✓ Branch 0 taken 49341 times.
✓ Branch 1 taken 680 times.
50021 if(i == 1)
28763 {
28764 680 cx += (scrolldir == down) ? 3 : 2;
28765 680 no_move += (scrolldir == down) ? 3 : 2;
28766 680 }
28767 50021 }
28768 else
28769 {
28770 //4 frames after we've finished scrolling of being still
28771
4/4
✓ Branch 0 taken 26402 times.
✓ Branch 1 taken 617661 times.
✓ Branch 2 taken 13201 times.
✓ Branch 3 taken 13201 times.
644063 if(cx == 0 && !end_frames)
28772 {
28773 13201 cx += 4;
28774 13201 no_move += 4;
28775 13201 end_frames = true;
28776 13201 }
28777 }
28778 694084 }
28779
28780 //Move Hero and the scroll position
28781
2/2
✓ Branch 0 taken 142491 times.
✓ Branch 1 taken 1463953 times.
1606444 if(!no_move)
28782 {
28783
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 332456 times.
✓ Branch 2 taken 246482 times.
✓ Branch 3 taken 414036 times.
✓ Branch 4 taken 470979 times.
1463953 switch(scrolldir)
28784 {
28785 case up:
28786 332456 sy -= step;
28787 332456 y += step;
28788 332456 break;
28789
28790 case down:
28791 246482 sy += step;
28792 246482 y -= step;
28793 246482 break;
28794
28795 case left:
28796 414036 sx -= step;
28797 414036 x += step;
28798 414036 break;
28799
28800 case right:
28801 470979 sx += step;
28802 470979 x -= step;
28803 470979 break;
28804 }
28805
28806 //bound Hero when me move him off the screen in the last couple of frames of scrolling
28807
2/2
✓ Branch 0 taken 29666 times.
✓ Branch 1 taken 1434287 times.
1463953 if(y > 160) y = 160;
28808
28809
2/2
✓ Branch 0 taken 21952 times.
✓ Branch 1 taken 1442001 times.
1463953 if(y < 0) y = 0;
28810
28811
2/2
✓ Branch 0 taken 25812 times.
✓ Branch 1 taken 1438141 times.
1463953 if(x > 240) x = 240;
28812
28813
2/2
✓ Branch 0 taken 29326 times.
✓ Branch 1 taken 1434627 times.
1463953 if(x < 0) x = 0;
28814
28815
4/4
✓ Branch 0 taken 1463707 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1463697 times.
1463953 if(ladderx > 0 || laddery > 0)
28816 {
28817 // If the ladder moves on both axes, the player can
28818 // gradually shift it by going back and forth
28819
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
256 if(scrolldir==up || scrolldir==down)
28820 laddery = y.getInt();
28821 else
28822 256 ladderx = x.getInt();
28823 256 }
28824 1463953 }
28825
28826 //Drawing
28827 1606444 tx = sx;
28828 1606444 ty = sy;
28829 1606444 tx2 = sx;
28830 1606444 ty2 = sy;
28831
28832
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 485490 times.
✓ Branch 2 taken 290276 times.
✓ Branch 3 taken 426870 times.
✓ Branch 4 taken 403808 times.
1606444 switch(scrolldir)
28833 {
28834 case right:
28835 485490 FFCore.ScrollingData[SCROLLDATA_NX] = 256-tx2;
28836 485490 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
28837 485490 FFCore.ScrollingData[SCROLLDATA_OX] = -tx2;
28838 485490 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
28839 485490 tx -= 256;
28840 485490 break;
28841
28842 case down:
28843 290276 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
28844 290276 FFCore.ScrollingData[SCROLLDATA_NY] = 176-ty2;
28845 290276 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
28846 290276 FFCore.ScrollingData[SCROLLDATA_OY] = -ty2;
28847 290276 ty -= 176;
28848 290276 break;
28849
28850 case left:
28851 426870 FFCore.ScrollingData[SCROLLDATA_NX] = -tx2;
28852 426870 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
28853 426870 FFCore.ScrollingData[SCROLLDATA_OX] = 256-tx2;
28854 426870 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
28855 426870 tx2 -= 256;
28856 426870 break;
28857
28858 case up:
28859 403808 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
28860 403808 FFCore.ScrollingData[SCROLLDATA_NY] = -ty2;
28861 403808 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
28862 403808 FFCore.ScrollingData[SCROLLDATA_OY] = 176-ty2;
28863 403808 ty2 -= 176;
28864 403808 break;
28865 }
28866
28867 //FFScript.OnWaitdraw()
28868 1606444 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
28869
28870 1606444 FFCore.runGenericPassiveEngine(SCR_TIMING_PRE_DRAW);
28871 1606444 clear_bitmap(scrollbuf);
28872 1606444 clear_bitmap(framebuf);
28873 1606444 clear_info_bmp();
28874
28875 1606444 combotile_add_x = 0;
28876 1606444 combotile_add_y = playing_field_offset;
28877
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 403808 times.
✓ Branch 2 taken 290276 times.
✓ Branch 3 taken 426870 times.
✓ Branch 4 taken 485490 times.
1606444 switch(scrolldir)
28878 {
28879 case up:
28880
2/2
✓ Branch 0 taken 403130 times.
✓ Branch 1 taken 678 times.
403808 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
28881
28882
2/2
✓ Branch 0 taken 403469 times.
✓ Branch 1 taken 339 times.
403808 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, -176+playing_field_offset, 3);
28883
28884
2/2
✓ Branch 0 taken 402623 times.
✓ Branch 1 taken 1185 times.
403808 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
28885
28886
2/2
✓ Branch 0 taken 402923 times.
✓ Branch 1 taken 885 times.
403808 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, -176+playing_field_offset, 3);
28887
28888 // Draw both screens' background layer primitives together, after both layers' combos.
28889 // Not ideal, but probably good enough for all realistic purposes.
28890
4/4
✓ Branch 0 taken 678 times.
✓ Branch 1 taken 403130 times.
✓ Branch 2 taken 402791 times.
✓ Branch 3 taken 1017 times.
403808 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
28891
28892
4/4
✓ Branch 0 taken 1185 times.
✓ Branch 1 taken 402623 times.
✓ Branch 2 taken 402373 times.
✓ Branch 3 taken 1435 times.
403808 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
28893
28894 403808 combotile_add_y -= sy;
28895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403808 times.
403808 if(lenscheck(newscr,0)) putscr(scrollbuf, 0, 0, newscr);
28896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403808 times.
403808 if(lenscheck(oldscr,0)) putscr(scrollbuf, 0, 176, oldscr);
28897 403808 break;
28898
28899 case down:
28900
2/2
✓ Branch 0 taken 290125 times.
✓ Branch 1 taken 151 times.
290276 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, -176+playing_field_offset, 2);
28901
28902
2/2
✓ Branch 0 taken 289938 times.
✓ Branch 1 taken 338 times.
290276 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
28903
28904
2/2
✓ Branch 0 taken 289826 times.
✓ Branch 1 taken 450 times.
290276 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, -176+playing_field_offset, 2);
28905
28906
2/2
✓ Branch 0 taken 289526 times.
✓ Branch 1 taken 750 times.
290276 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
28907
28908
4/4
✓ Branch 0 taken 151 times.
✓ Branch 1 taken 290125 times.
✓ Branch 2 taken 289787 times.
✓ Branch 3 taken 489 times.
290276 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
28909
28910
4/4
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 289826 times.
✓ Branch 2 taken 289376 times.
✓ Branch 3 taken 900 times.
290276 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
28911
28912 290276 combotile_add_y -= sy;
28913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290276 times.
290276 if(lenscheck(oldscr,0)) putscr(scrollbuf, 0, 0, oldscr);
28914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290276 times.
290276 if(lenscheck(newscr,0)) putscr(scrollbuf, 0, 176, newscr);
28915 290276 break;
28916
28917 case left:
28918
2/2
✓ Branch 0 taken 426852 times.
✓ Branch 1 taken 18 times.
426870 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
28919
28920
2/2
✓ Branch 0 taken 426804 times.
✓ Branch 1 taken 66 times.
426870 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, -256, playing_field_offset, 3);
28921
28922
2/2
✓ Branch 0 taken 425064 times.
✓ Branch 1 taken 1806 times.
426870 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
28923
28924
2/2
✓ Branch 0 taken 424998 times.
✓ Branch 1 taken 1872 times.
426870 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, -256, playing_field_offset, 3);
28925
28926
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 426852 times.
✓ Branch 2 taken 426786 times.
✓ Branch 3 taken 84 times.
426870 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
28927
28928
4/4
✓ Branch 0 taken 1806 times.
✓ Branch 1 taken 425064 times.
✓ Branch 2 taken 424602 times.
✓ Branch 3 taken 2268 times.
426870 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
28929
28930 426870 combotile_add_x -= sx;
28931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 426870 times.
426870 if(lenscheck(newscr,0)) putscr(scrollbuf, 0, 0, newscr);
28932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 426870 times.
426870 if(lenscheck(oldscr,0)) putscr(scrollbuf, 256, 0, oldscr);
28933 426870 break;
28934
28935 case right:
28936
1/2
✓ Branch 0 taken 485490 times.
✗ Branch 1 not taken.
485490 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, -256, playing_field_offset, 2);
28937
28938
2/2
✓ Branch 0 taken 485472 times.
✓ Branch 1 taken 18 times.
485490 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
28939
28940
2/2
✓ Branch 0 taken 483918 times.
✓ Branch 1 taken 1572 times.
485490 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, -256, playing_field_offset, 2);
28941
28942
2/2
✓ Branch 0 taken 483918 times.
✓ Branch 1 taken 1572 times.
485490 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
28943
28944
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 485490 times.
✓ Branch 2 taken 485472 times.
✓ Branch 3 taken 18 times.
485490 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
28945
28946
4/4
✓ Branch 0 taken 1572 times.
✓ Branch 1 taken 483918 times.
✓ Branch 2 taken 483456 times.
✓ Branch 3 taken 2034 times.
485490 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
28947
28948 485490 combotile_add_x -= sx;
28949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 485490 times.
485490 if(lenscheck(oldscr,0)) putscr(scrollbuf, 0, 0, oldscr);
28950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 485490 times.
485490 if(lenscheck(newscr,0)) putscr(scrollbuf, 256, 0, newscr);
28951 485490 break;
28952 }
28953
28954 1606444 combotile_add_x = 0;
28955 1606444 combotile_add_y = 0;
28956
28957 1606444 blit(scrollbuf, framebuf, sx, sy, 0, playing_field_offset, 256, 168);
28958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1606444 times.
1606444 if(lenscheck(newscr,0))
28959 1606444 do_primitives(framebuf, 0, newscr, 0, playing_field_offset);
28960
28961 1606444 do_layer(framebuf, 0, 1, oldscr, tx2, ty2, 3);
28962 1606444 do_layer(framebuf, 0, 1, newscr, tx, ty, 2, false, true);
28963
28964
2/2
✓ Branch 0 taken 1160654 times.
✓ Branch 1 taken 445790 times.
1606444 if(get_qr(qr_FFCSCROLL))
28965 {
28966 445790 do_layer(framebuf, -3, 0, oldscr, tx2, ty2, 3, true); //ffcs
28967 445790 do_layer(framebuf, -3, 0, newscr, tx, ty, 2, true);
28968 445790 }
28969
28970
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 1605683 times.
1606444 if(!(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) ) do_layer(framebuf, 0, 2, oldscr, tx2, ty2, 3);
28971
2/2
✓ Branch 0 taken 847 times.
✓ Branch 1 taken 1605597 times.
1606444 if(!(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, newscr, tx, ty, 2, false, !(oldscr->flags7&fLAYER2BG));
28972
28973 //push blocks
28974
2/2
✓ Branch 0 taken 16458 times.
✓ Branch 1 taken 1589986 times.
1606444 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
28975 {
28976 1589986 do_layer(framebuf, -2, 0, oldscr, tx2, ty2, 3);
28977 1589986 do_layer(framebuf, -2, 0, newscr, tx, ty, 2);
28978
2/2
✓ Branch 0 taken 1549830 times.
✓ Branch 1 taken 40156 times.
1589986 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
28979 {
28980 40156 do_layer(framebuf, -2, 1, oldscr, tx2, ty2, 3);
28981 40156 do_layer(framebuf, -2, 1, newscr, tx, ty, 2);
28982 40156 do_layer(framebuf, -2, 2, oldscr, tx2, ty2, 3);
28983 40156 do_layer(framebuf, -2, 2, newscr, tx, ty, 2);
28984 40156 }
28985 1589986 do_primitives(framebuf, SPLAYER_PUSHBLOCK, newscr, 0, playing_field_offset);
28986 1589986 }
28987
28988 1606444 do_walkflags(oldscr, tx2, ty2,3); //show walkflags if the cheat is on
28989 1606444 do_walkflags(newscr, tx, ty,2);
28990
28991 1606444 do_effectflags(oldscr, tx2, ty2,3); //show effectflags if the cheat is on
28992 1606444 do_effectflags(newscr, tx, ty,2);
28993
28994
28995 1606444 putscrdoors(framebuf, 0-tx2, 0-ty2+playing_field_offset, oldscr);
28996 1606444 putscrdoors(framebuf, 0-tx, 0-ty+playing_field_offset, newscr);
28997 1606444 herostep();
28998
1/2
✓ Branch 0 taken 1606444 times.
✗ Branch 1 not taken.
1606444 if(isForceFaceUp) dir = up;
28999
29000
5/6
✓ Branch 0 taken 1605680 times.
✓ Branch 1 taken 764 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1604916 times.
✓ Branch 4 taken 1605680 times.
✓ Branch 5 taken 1605680 times.
1606444 if((z > 0 || fakez > 0) && (!get_qr(qr_SHADOWSFLICKER) || frame&1))
29001 {
29002 3210596 drawshadow(framebuf, get_qr(qr_TRANSSHADOWS) != 0);
29003 3210596 }
29004
29005
4/4
✓ Branch 0 taken 615767 times.
✓ Branch 1 taken 990677 times.
✓ Branch 2 taken 295458 times.
✓ Branch 3 taken 320309 times.
1606444 if(!isdungeon() || get_qr(qr_FREEFORM))
29006 {
29007
2/2
✓ Branch 0 taken 37438 times.
✓ Branch 1 taken 1286135 times.
1323573 for (int i = 0; i < decorations.Count(); i++)
29008 {
29009 37438 auto sprite = (decoration*)decorations.spr(i);
29010
2/2
✓ Branch 0 taken 37008 times.
✓ Branch 1 taken 430 times.
37438 if (!sprite->is_drawn_with_offset())
29011 {
29012 // NOTE: if decoration sprites are ever exposed to zscript, this modification
29013 // needs to tack on to existing values for x/yofs.
29014 430 sprite->xofs = -tx2;
29015 430 sprite->yofs = -ty2+playing_field_offset;
29016 430 }
29017 37438 }
29018
29019 1286135 draw_under(framebuf); //draw the ladder or raft
29020 1286135 decorations.draw2(framebuf, true);
29021 1286135 draw(framebuf); //Hero
29022 1286135 decorations.draw(framebuf, true);
29023 1286135 }
29024
29025
2/2
✓ Branch 0 taken 5079 times.
✓ Branch 1 taken 1601365 times.
1606444 if(!(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, oldscr, tx2, ty2, 3);
29026
29027 1606444 do_layer(framebuf, 0, 4, oldscr, tx2, ty2, 3); //layer 4
29028 1606444 do_layer(framebuf, -1, 0, oldscr, tx2, ty2, 3); //overhead combos
29029
2/2
✓ Branch 0 taken 1561832 times.
✓ Branch 1 taken 44612 times.
1606444 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
29030 {
29031 44612 do_layer(framebuf, -1, 1, oldscr, tx2, ty2, 3); //overhead combos
29032 44612 do_layer(framebuf, -1, 2, oldscr, tx2, ty2, 3); //overhead combos
29033 44612 }
29034 1606444 do_layer(framebuf, 0, 5, oldscr, tx2, ty2, 3); //layer 5
29035 1606444 do_layer(framebuf, -4, 0, oldscr, tx2, ty2, 3, true); //overhead FFCs
29036 1606444 do_layer(framebuf, 0, 6, oldscr, tx2, ty2, 3); //layer 6
29037
29038
2/2
✓ Branch 0 taken 5013 times.
✓ Branch 1 taken 1601431 times.
1606444 if(!(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, newscr, tx, ty, 2, false, !(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)));
29039
29040 1606444 do_layer(framebuf, 0, 4, newscr, tx, ty, 2, false, true); //layer 4
29041 1606444 do_layer(framebuf, -1, 0, newscr, tx, ty, 2); //overhead combos
29042
2/2
✓ Branch 0 taken 1561832 times.
✓ Branch 1 taken 44612 times.
1606444 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
29043 {
29044 44612 do_layer(framebuf, -1, 1, newscr, tx, ty, 2); //overhead combos
29045 44612 do_layer(framebuf, -1, 2, newscr, tx, ty, 2); //overhead combos
29046 44612 }
29047 1606444 do_layer(framebuf, 0, 5, newscr, tx, ty, 2, false, true); //layer 5
29048 1606444 do_layer(framebuf, -4, 0, newscr, tx, ty, 2, true); //overhead FFCs
29049 1606444 do_layer(framebuf, 0, 6, newscr, tx, ty, 2, false, true); //layer 6
29050
29051
29052
1/2
✓ Branch 0 taken 1606444 times.
✗ Branch 1 not taken.
1606444 if(msg_bg_display_buf->clip == 0)
29053 {
29054 blit_msgstr_bg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
29055 }
29056
1/2
✓ Branch 0 taken 1606444 times.
✗ Branch 1 not taken.
1606444 if(msg_portrait_display_buf->clip == 0)
29057 {
29058 blit_msgstr_prt(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
29059 }
29060
1/2
✓ Branch 0 taken 1606444 times.
✗ Branch 1 not taken.
1606444 if(msg_txt_display_buf->clip == 0)
29061 {
29062 blit_msgstr_fg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
29063 }
29064
29065
6/6
✓ Branch 0 taken 50906 times.
✓ Branch 1 taken 1555538 times.
✓ Branch 2 taken 42063 times.
✓ Branch 3 taken 8843 times.
✓ Branch 4 taken 239 times.
✓ Branch 5 taken 41824 times.
1606444 if(get_qr(qr_NEW_DARKROOM) && (room_is_dark||room_was_dark))
29066 {
29067 9082 clear_darkroom_bitmaps();
29068 9082 calc_darkroom_combos(true);
29069 9082 calc_darkroom_hero(FFCore.ScrollingData[SCROLLDATA_NX], FFCore.ScrollingData[SCROLLDATA_NY],FFCore.ScrollingData[SCROLLDATA_OX], FFCore.ScrollingData[SCROLLDATA_OY]);
29070 9082 }
29071
29072
4/4
✓ Branch 0 taken 50906 times.
✓ Branch 1 taken 1555538 times.
✓ Branch 2 taken 14411 times.
✓ Branch 3 taken 36495 times.
1606444 if(get_qr(qr_NEW_DARKROOM) && get_qr(qr_NEWDARK_L6))
29073 {
29074 36495 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
29075 36495 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
29076 36495 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
29077
2/2
✓ Branch 0 taken 28127 times.
✓ Branch 1 taken 8368 times.
36495 if(room_is_dark)
29078 {
29079
1/2
✓ Branch 0 taken 8368 times.
✗ Branch 1 not taken.
8368 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
29080 {
29081 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
29082 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
29083 }
29084
29085 8368 color_map = &trans_table2;
29086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8368 times.
8368 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
29087 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
29088 else
29089 8368 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
29090 8368 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
29091 8368 color_map = &trans_table;
29092 8368 }
29093
2/2
✓ Branch 0 taken 28199 times.
✓ Branch 1 taken 8296 times.
36495 if(room_was_dark)
29094 {
29095
1/2
✓ Branch 0 taken 8296 times.
✗ Branch 1 not taken.
8296 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
29096 {
29097 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
29098 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
29099 }
29100
29101 8296 color_map = &trans_table2;
29102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8296 times.
8296 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
29103 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
29104 else
29105 8296 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
29106 8296 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
29107 8296 color_map = &trans_table;
29108 8296 }
29109 36495 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
29110 36495 }
29111 1606444 put_passive_subscr(framebuf, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
29112
2/2
✓ Branch 0 taken 1032803 times.
✓ Branch 1 taken 573641 times.
1606444 if(get_qr(qr_SUBSCREENOVERSPRITES))
29113 573641 do_primitives(framebuf, 7, newscr, 0, playing_field_offset);
29114
29115
4/4
✓ Branch 0 taken 50906 times.
✓ Branch 1 taken 1555538 times.
✓ Branch 2 taken 36495 times.
✓ Branch 3 taken 14411 times.
1606444 if(get_qr(qr_NEW_DARKROOM) && !get_qr(qr_NEWDARK_L6))
29116 {
29117 14411 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
29118 14411 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
29119 14411 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
29120
2/2
✓ Branch 0 taken 13936 times.
✓ Branch 1 taken 475 times.
14411 if(room_is_dark)
29121 {
29122
1/2
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
475 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
29123 {
29124 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
29125 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
29126 }
29127
29128 475 color_map = &trans_table2;
29129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
29130 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
29131 else
29132 475 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
29133 475 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
29134 475 color_map = &trans_table;
29135 475 }
29136
2/2
✓ Branch 0 taken 13970 times.
✓ Branch 1 taken 441 times.
14411 if(room_was_dark)
29137 {
29138
1/2
✓ Branch 0 taken 441 times.
✗ Branch 1 not taken.
441 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
29139 {
29140 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
29141 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
29142 }
29143
29144 441 color_map = &trans_table2;
29145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 441 times.
441 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
29146 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
29147 else
29148 441 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
29149 441 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
29150 441 color_map = &trans_table;
29151 441 }
29152 14411 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
29153 14411 }
29154 1606444 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DRAW);
29155
29156 //end drawing
29157 1606444 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
29158 1606444 advanceframe(true/*,true,false*/);
29159
29160 //Don't clear the last frame, unless 'fixed'
29161
4/4
✓ Branch 0 taken 27552 times.
✓ Branch 1 taken 1578892 times.
✓ Branch 2 taken 1720 times.
✓ Branch 3 taken 25832 times.
1606444 if(cx > 0 || get_qr(qr_FIXSCRIPTSDURINGSCROLLING))
29162 1580612 script_drawing_commands.Clear();
29163 1606444 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
29164 1606444 actiontype lastaction = action;
29165 1606444 action=scrolling; FFCore.setHeroAction(scrolling);
29166 1606444 FFCore.runF6Engine();
29167 1606444 action=lastaction; FFCore.setHeroAction(lastaction);
29168 1606444 } //end main scrolling loop
29169 27552 currdmap = olddmap;
29170
29171 27552 clear_bitmap(msg_txt_display_buf);
29172 27552 set_clip_state(msg_txt_display_buf, 1);
29173 27552 clear_bitmap(msg_bg_display_buf);
29174 27552 set_clip_state(msg_bg_display_buf, 1);
29175 27552 clear_bitmap(msg_portrait_display_buf);
29176 27552 set_clip_state(msg_portrait_display_buf, 1);
29177
29178 //Move hero to the other side of the screen if scrolling's not turned on
29179
1/2
✓ Branch 0 taken 27552 times.
✗ Branch 1 not taken.
27552 if(get_qr(qr_NOSCROLL))
29180 {
29181 switch(scrolldir)
29182 {
29183 case up:
29184 y = 160;
29185 break;
29186
29187 case down:
29188 y = 0;
29189 break;
29190
29191 case left:
29192 x = 240;
29193 break;
29194
29195 case right:
29196 x = 0;
29197 break;
29198 }
29199 }
29200
29201
3/4
✓ Branch 0 taken 27538 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 27552 times.
✗ Branch 3 not taken.
27552 if((z > 0 || fakez > 0) && isSideViewHero())
29202 {
29203 y -= z;
29204 y -= fakez;
29205 z = 0;
29206 fakez = 0;
29207 }
29208
29209 27552 combotile_add_x = 0;
29210 27552 combotile_add_y = 0;
29211
29212 27552 set_respawn_point(false);
29213 27552 trySideviewLadder();
29214 27552 warpx = -1;
29215 27552 warpy = -1;
29216
29217 27552 screenscrolling = false;
29218 27552 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
29219 27552 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
29220 27552 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
29221 27552 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
29222 27552 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
29223
29224
2/2
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 26590 times.
27552 if(destdmap != -1)
29225 {
29226 962 bool changedlevel = false;
29227 962 bool changeddmap = false;
29228
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 823 times.
962 if(olddmap != destdmap)
29229 {
29230 823 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
29231 823 changeddmap = true;
29232 823 }
29233
2/2
✓ Branch 0 taken 818 times.
✓ Branch 1 taken 144 times.
962 if(DMaps[olddmap].level != DMaps[destdmap].level)
29234 {
29235 144 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
29236 144 changedlevel = true;
29237 144 }
29238 962 dlevel = DMaps[destdmap].level;
29239 962 currdmap = destdmap;
29240
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 823 times.
962 if(changeddmap)
29241 {
29242 823 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
29243 823 }
29244
2/2
✓ Branch 0 taken 818 times.
✓ Branch 1 taken 144 times.
962 if(changedlevel)
29245 {
29246 144 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
29247 144 }
29248 962 }
29249
29250 //if Hero is going from non-water to water, and we set his animation to "hopping" above, we must now
29251 //change it to swimming - since we have manually moved Hero onto the first tile, the hopping code
29252 //will get confused and try to hop Hero onto the next (possibly nonexistant) water tile in his current
29253 //direction. -DD
29254
29255
2/2
✓ Branch 0 taken 27204 times.
✓ Branch 1 taken 348 times.
27552 if(nowinwater)
29256 {
29257 348 SetSwim();
29258 348 hopclk = 0xFF;
29259 348 }
29260
29261 // NES behaviour: Fade to light after scrolling
29262 27552 lighting(false, false); // No, we don't need to set naturaldark...
29263
29264 27552 init_dmap();
29265 27552 putscr(scrollbuf,0,0,newscr);
29266 27552 putscrdoors(scrollbuf,0,0,newscr);
29267
29268 // Check for raft flags
29269
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 26394 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 25557 times.
53166 if((get_qr(qr_BROKEN_RAFT_SCROLL) || lastaction == rafting)
29270
4/4
✓ Branch 0 taken 25940 times.
✓ Branch 1 taken 1612 times.
✓ Branch 2 taken 25614 times.
✓ Branch 3 taken 326 times.
27552 && action!=rafting && hopclk==0 && !toogam)
29271 {
29272
3/4
✓ Branch 0 taken 25552 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25552 times.
25557 if(MAPFLAG(x,y)==mfRAFT||MAPCOMBOFLAG(x,y)==mfRAFT)
29273 {
29274 5 sfx(tmpscr->secretsfx);
29275 5 action=rafting; FFCore.setHeroAction(rafting);
29276 5 raftclk=0;
29277 5 }
29278
29279 // Half a tile off?
29280
6/8
✓ Branch 0 taken 19391 times.
✓ Branch 1 taken 6161 times.
✓ Branch 2 taken 6918 times.
✓ Branch 3 taken 12473 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 13079 times.
✓ Branch 6 taken 25552 times.
✗ Branch 7 not taken.
38631 else if((dir==left || dir==right) && (MAPFLAG(x,y+8)==mfRAFT||MAPCOMBOFLAG(x,y+8)==mfRAFT))
29281 {
29282 sfx(tmpscr->secretsfx);
29283 action=rafting; FFCore.setHeroAction(rafting);
29284 raftclk=0;
29285 }
29286 25557 }
29287
29288 27552 opendoors=0;
29289 27552 markBmap(-1);
29290
29291
2/2
✓ Branch 0 taken 18848 times.
✓ Branch 1 taken 8704 times.
27552 if(isdungeon())
29292 {
29293
4/4
✓ Branch 0 taken 5100 times.
✓ Branch 1 taken 1694 times.
✓ Branch 2 taken 1904 times.
✓ Branch 3 taken 6 times.
8704 switch(tmpscr->door[scrolldir^1])
29294 {
29295 case dNONE:
29296 6 dir = scrolldir;
29297 6 break;
29298 case dOPEN:
29299 case dUNLOCKED:
29300 case dOPENBOSS:
29301 5100 dir = scrolldir;
29302
29303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5100 times.
5100 if(action!=rafting)
29304 5100 stepforward(diagonalMovement?11:12, false);
29305
29306 5100 break;
29307
29308 case dSHUTTER:
29309 case d1WAYSHUTTER:
29310 1694 dir = scrolldir;
29311
29312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
1694 if(action!=rafting)
29313 1694 stepforward(diagonalMovement?21:24, false);
29314
29315 1694 putdoor(scrollbuf,0,scrolldir^1,tmpscr->door[scrolldir^1]);
29316 1694 opendoors=-4;
29317 1694 sfx(WAV_DOOR);
29318 1694 break;
29319
29320 default:
29321 1904 dir = scrolldir;
29322
29323
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 1857 times.
1904 if(action!=rafting)
29324 1857 stepforward(diagonalMovement?21:24, false);
29325 1904 }
29326 8704 }
29327
29328
1/2
✓ Branch 0 taken 27552 times.
✗ Branch 1 not taken.
27552 if(isForceFaceUp) dir = up;
29329
29330
1/2
✓ Branch 0 taken 27552 times.
✗ Branch 1 not taken.
27552 if(action == scrolling)
29331 {
29332 action=none; FFCore.setHeroAction(none);
29333 }
29334
29335
3/4
✓ Branch 0 taken 27520 times.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27520 times.
27552 if(action != attacking && action != sideswimattacking)
29336 {
29337 27520 charging = 0;
29338 27520 tapping = false;
29339 27520 }
29340
29341 27552 map_bkgsfx(true);
29342
29343
2/2
✓ Branch 0 taken 27518 times.
✓ Branch 1 taken 34 times.
27552 if(newscr->flags2&fSECRET)
29344 {
29345 34 sfx(newscr->secretsfx);
29346 34 }
29347
29348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27552 times.
27552 if (updatemusic)
29349 {
29350 27552 playLevelMusic();
29351
1/2
✓ Branch 0 taken 27552 times.
✗ Branch 1 not taken.
27552 if (musicrevert)
29352 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
29353 27552 }
29354
29355 // It happens that all decorations that are not drawn with an offset
29356 // are temporary sprites (like combo sprites) that should never carry over.
29357
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 27552 times.
28244 for (int i = decorations.Count()-1; i >=0; i--)
29358 {
29359 692 auto sprite = (decoration*)decorations.spr(i);
29360
2/2
✓ Branch 0 taken 685 times.
✓ Branch 1 taken 7 times.
692 if (!sprite->is_drawn_with_offset())
29361 7 decorations.remove(sprite); // TODO: improve deletions by adding remove_by_index
29362 692 }
29363
29364 27552 newscr_clk = frame;
29365 27552 activated_timed_warp=false;
29366 27552 loadside = scrolldir^1;
29367 27552 FFCore.clear_combo_scripts();
29368 27552 eventlog_mapflags();
29369 27552 decorations.animate(); //continue to animate tall grass during scrolling
29370
2/2
✓ Branch 0 taken 25832 times.
✓ Branch 1 taken 1720 times.
27552 if(get_qr(qr_FIXSCRIPTSDURINGSCROLLING))
29371 {
29372
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 1670 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 44 times.
1720 if(olddmap == newdmap || (replay_version_check(0, 15)))
29373 {
29374 1676 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
29375 1676 }
29376 1720 }
29377
2/2
✓ Branch 0 taken 26111 times.
✓ Branch 1 taken 1441 times.
27552 if(!get_qr(qr_SCROLLWARP_NO_RESET_FRAME))
29378 1441 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
29379 27555 }
29380
29381
29382
29383 // How much to reduce Hero's damage, taking into account various rings.
29384 15170 int32_t HeroClass::ringpower(int32_t dmg, bool noPeril, bool noRing)
29385 {
29386
1/2
✓ Branch 0 taken 15170 times.
✗ Branch 1 not taken.
15170 if(dmg < 0) return dmg; //Don't reduce healing
29387
2/2
✓ Branch 0 taken 14443 times.
✓ Branch 1 taken 727 times.
15170 if ( get_qr(qr_BROKEN_RING_POWER) )
29388 {
29389 14443 int32_t divisor = 1;
29390 14443 float percentage = 1;
29391 14443 int32_t itemid = current_item_id(itype_ring);
29392 14443 bool usering = false;
29393
29394
4/4
✓ Branch 0 taken 10813 times.
✓ Branch 1 taken 3630 times.
✓ Branch 2 taken 324 times.
✓ Branch 3 taken 10489 times.
14443 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
29395 {
29396 10489 usering = true;
29397 10489 paymagiccost(itemid);
29398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10489 times.
10489 if(itemsbuf[itemid].flags & item_flag2)//"Divisor is Percentage Multiplier" flag
29399 {
29400 percentage *= itemsbuf[itemid].power/100.0;
29401 }
29402 else
29403 {
29404 10489 divisor *= itemsbuf[itemid].power;
29405 }
29406 10489 }
29407
29408 /* Now for the Peril Ring */
29409 14443 itemid = current_item_id(itype_perilring);
29410
29411
8/10
✓ Branch 0 taken 2844 times.
✓ Branch 1 taken 11599 times.
✓ Branch 2 taken 2698 times.
✓ Branch 3 taken 146 times.
✓ Branch 4 taken 402 times.
✓ Branch 5 taken 2296 times.
✓ Branch 6 taken 402 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 402 times.
14443 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
29412 {
29413 402 usering = true;
29414 402 paymagiccost(itemid);
29415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402 times.
402 if(itemsbuf[itemid].flags & item_flag2)//"Divisor is Percentage Multiplier" flag
29416 {
29417 percentage *= itemsbuf[itemid].power/100.0;
29418 }
29419 else
29420 {
29421 402 divisor *= itemsbuf[itemid].power;
29422 }
29423 402 }
29424
29425 // Ring divisor of 0 = no damage. -L
29426
4/6
✓ Branch 0 taken 10507 times.
✓ Branch 1 taken 3936 times.
✓ Branch 2 taken 10507 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10507 times.
14443 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
29427 return 0;
29428
29429
1/2
✓ Branch 0 taken 14443 times.
✗ Branch 1 not taken.
14443 if( percentage < 0 ) percentage = (percentage * -1) + 1; //Negative percentage = that percent MORE damage -V
29430
29431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14443 times.
14443 if ( divisor < 0 ) return dmg * percentage * (divisor*-1);
29432
1/2
✓ Branch 0 taken 14443 times.
✗ Branch 1 not taken.
14443 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
29433
29434 }
29435 else
29436 {
29437 727 double divisor = 1;
29438 727 double percentage = 1;
29439 727 int32_t itemid = current_item_id(itype_ring);
29440 727 bool usering = false;
29441
29442
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 724 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
727 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
29443 {
29444 3 usering = true;
29445 3 paymagiccost(itemid);
29446
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(itemsbuf[itemid].flags & item_flag2)//"Divisor is Percentage Multiplier" flag
29447 {
29448 1 double perc = itemsbuf[itemid].power/100.0;
29449
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
29450 1 percentage *= perc;
29451 1 }
29452 else
29453 {
29454
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].power < 0)
29455 divisor /= -(itemsbuf[itemid].power);
29456 2 else divisor *= itemsbuf[itemid].power;
29457 }
29458 3 }
29459
29460 /* Now for the Peril Ring */
29461 727 itemid = current_item_id(itype_perilring);
29462
29463
4/10
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 725 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
727 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
29464 {
29465 usering = true;
29466 paymagiccost(itemid);
29467 if(itemsbuf[itemid].flags & item_flag2)//"Divisor is Percentage Multiplier" flag
29468 {
29469 double perc = itemsbuf[itemid].power/100.0;
29470 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
29471 percentage *= perc;
29472 }
29473 else
29474 {
29475 if(itemsbuf[itemid].power < 0)
29476 divisor /= -(itemsbuf[itemid].power);
29477 else divisor *= itemsbuf[itemid].power;
29478 }
29479 }
29480
29481 // Ring divisor of 0 = no damage. -L
29482
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 724 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
727 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
29483 return 0;
29484
29485 //if ( divisor < 0 ) return dmg * percentage * (divisor*-1); //handle this further up now
29486
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
29487 }
29488 15170 }
29489
29490 // Should swinging the hammer make the 'pound' sound?
29491 // Or is Hero just hitting air?
29492 6470 bool HeroClass::sideviewhammerpound()
29493 {
29494 6470 int32_t wx=0,wy=0;
29495
29496
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1022 times.
✓ Branch 2 taken 1520 times.
✓ Branch 3 taken 2131 times.
✓ Branch 4 taken 1797 times.
6470 switch(dir)
29497 {
29498 case up:
29499 1022 wx=-1;
29500 1022 wy=-15;
29501
29502
1/2
✓ Branch 0 taken 1022 times.
✗ Branch 1 not taken.
1022 if(isSideViewHero()) wy+=8;
29503
29504 1022 break;
29505
29506 case down:
29507 1520 wx=8;
29508 1520 wy=28;
29509
29510
1/2
✓ Branch 0 taken 1520 times.
✗ Branch 1 not taken.
1520 if(isSideViewHero()) wy-=8;
29511
29512 1520 break;
29513
29514 case left:
29515 2131 wx=-8;
29516 2131 wy=14;
29517
29518
2/2
✓ Branch 0 taken 2125 times.
✓ Branch 1 taken 6 times.
2131 if(isSideViewHero()) wy+=8;
29519
29520 2131 break;
29521
29522 case right:
29523 1797 wx=21;
29524 1797 wy=14;
29525
29526
1/2
✓ Branch 0 taken 1797 times.
✗ Branch 1 not taken.
1797 if(isSideViewHero()) wy+=8;
29527
29528 1797 break;
29529 }
29530
29531
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6464 times.
6470 if(!isSideViewHero())
29532 {
29533
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 6455 times.
6464 return (COMBOTYPE(x+wx,y+wy)!=cSHALLOWWATER && !iswaterex(MAPCOMBO(x+wx,y+wy), currmap, currscr, -1, x+wx,y+wy));
29534 }
29535
29536
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
29537
29538 if(dir==left || dir==right)
29539 {
29540 wx+=16;
29541
29542 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
29543 }
29544
29545 return false;
29546 6470 }
29547
29548 // The following are only used for Hero damage. Damage is in quarter hearts.
29549 9139 int32_t enemy_dp(int32_t index)
29550 {
29551 9139 return (((enemy*)guys.spr(index))->dp)*(game->get_ene_dmgmult());
29552 }
29553
29554 5422 int32_t ewpn_dp(int32_t index)
29555 {
29556 5422 return (((weapon*)Ewpns.spr(index))->power)*(game->get_ene_dmgmult());
29557 }
29558
29559 43 int32_t lwpn_dp(int32_t index)
29560 {
29561 43 return (((weapon*)Lwpns.spr(index))->power)*(game->get_ene_dmgmult());
29562 }
29563
29564 135987170 bool checkbunny(int32_t itemid)
29565 {
29566
3/4
✓ Branch 0 taken 135901086 times.
✓ Branch 1 taken 86084 times.
✓ Branch 2 taken 86084 times.
✗ Branch 3 not taken.
135987170 return !Hero.BunnyClock() || (itemid > 0 && itemsbuf[itemid].flags&item_bunny_enabled);
29567 }
29568
29569 16727272 bool usesSwordJinx(int32_t itemid)
29570 {
29571 16727272 itemdata const& it = itemsbuf[itemid];
29572 16727272 bool ret = (it.family==itype_sword);
29573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16727272 times.
16727272 if(it.flags & item_flip_jinx) return !ret;
29574 16727272 return ret;
29575 16727272 }
29576 40345315 bool checkitem_jinx(int32_t itemid)
29577 {
29578 40345315 itemdata const& it = itemsbuf[itemid];
29579
2/2
✓ Branch 0 taken 6225 times.
✓ Branch 1 taken 40339090 times.
40345315 if(it.flags & item_jinx_immune) return true;
29580
2/2
✓ Branch 0 taken 31186248 times.
✓ Branch 1 taken 9152842 times.
40339090 if (it.family == itype_shield){
29581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31186248 times.
31186248 if(HeroShieldClk() != 0) return false;
29582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31186248 times.
31186248 if(it.flags & !item_flag9) //Active Shields should also check sword/item jinx flags
29583 {
29584 if (usesSwordJinx(itemid)) return HeroSwordClk() == 0;
29585 return HeroItemClk() == 0;
29586 }
29587 31186248 return true;
29588
29589 }
29590
2/2
✓ Branch 0 taken 8341533 times.
✓ Branch 1 taken 811309 times.
9152842 if(usesSwordJinx(itemid)) return HeroSwordClk() == 0;
29591 811309 return HeroItemClk() == 0;
29592 40345315 }
29593
29594 2 void stopCaneOfByrna()
29595 {
29596
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 2 times.
42 for(int32_t i=0; i<Lwpns.Count(); i++)
29597 {
29598 40 weapon *w = ((weapon*)Lwpns.spr(i));
29599
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 2 times.
40 if(w->id==wCByrna)
29600 2 w->dead=1;
29601 40 }
29602 2 }
29603
29604 /* Crashes if used by ffscript.cpp, in case LINKITEMD
29605 void stopCaneOfByrna()
29606 {
29607 byte prnt_cane = -1;
29608 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
29609 prnt_cane = ew->parentitem;
29610 for(int32_t i=0; i<Lwpns.Count(); i++)
29611 {
29612 weapon *w = ((weapon*)Lwpns.spr(i));
29613
29614 if(w->id==wCByrna)
29615 {
29616 w->dead=1;
29617 }
29618 }
29619 if ( prnt_cane > -1 )
29620 {
29621 stop_sfx(itemsbuf[prnt_cane].usesound);
29622 }
29623 }
29624 */
29625 //Check if there are no beams, kill sfx, and reset last_cane_of_byrna_item_id
29626 14167688 void HeroClass::cleanupByrna()
29627 {
29628
2/2
✓ Branch 0 taken 14167611 times.
✓ Branch 1 taken 77 times.
14167688 if ( last_cane_of_byrna_item_id > -1 )
29629 {
29630
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 75 times.
77 if ( !(Lwpns.idCount(wCByrna)) )
29631 {
29632 2 stop_sfx(itemsbuf[last_cane_of_byrna_item_id].usesound);
29633 2 last_cane_of_byrna_item_id = -1;
29634 2 }
29635 77 }
29636 14167688 }
29637
29638 // Used to find out if an item family is attached to one of the buttons currently pressed.
29639 4414437 bool isWpnPressed(int32_t itype)
29640 {
29641
4/4
✓ Branch 0 taken 527509 times.
✓ Branch 1 taken 3886928 times.
✓ Branch 2 taken 463054 times.
✓ Branch 3 taken 64455 times.
4414437 if((itype==getItemFamily(itemsbuf,Bwpn)) && DrunkcBbtn()) return true;
29642
4/4
✓ Branch 0 taken 1586352 times.
✓ Branch 1 taken 2763630 times.
✓ Branch 2 taken 653346 times.
✓ Branch 3 taken 933006 times.
4349982 if((itype==getItemFamily(itemsbuf,Awpn)) && DrunkcAbtn()) return true;
29643
4/4
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 3415546 times.
✓ Branch 2 taken 566 times.
✓ Branch 3 taken 864 times.
3416976 if((itype==getItemFamily(itemsbuf,Xwpn)) && DrunkcEx1btn()) return true;
29644
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 3416050 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 27 times.
3416112 if((itype==getItemFamily(itemsbuf,Ywpn)) && DrunkcEx2btn()) return true;
29645 3416077 return false;
29646 4414437 }
29647
29648 13600369 int32_t getWpnPressed(int32_t itype)
29649 {
29650
4/4
✓ Branch 0 taken 402438 times.
✓ Branch 1 taken 13197931 times.
✓ Branch 2 taken 393732 times.
✓ Branch 3 taken 8706 times.
13600369 if((itype==getItemFamily(itemsbuf,Bwpn)) && DrunkcBbtn()) return Bwpn&0xFFF;
29651
3/4
✓ Branch 0 taken 28064 times.
✓ Branch 1 taken 13563599 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28064 times.
13591663 if((itype==getItemFamily(itemsbuf,Awpn)) && DrunkcAbtn()) return Awpn&0xFFF;
29652
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13563599 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13563599 if((itype==getItemFamily(itemsbuf,Xwpn)) && DrunkcEx1btn()) return Xwpn&0xFFF;
29653
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13563599 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13563599 if((itype==getItemFamily(itemsbuf,Ywpn)) && DrunkcEx2btn()) return Ywpn&0xFFF;
29654
29655 13563599 return -1;
29656 13600369 }
29657
29658 14170183 int32_t getRocsPressed()
29659 {
29660 14170183 int32_t jumpid = current_item_id(itype_rocs,true,true);
29661
29662
2/2
✓ Branch 0 taken 352076 times.
✓ Branch 1 taken 13818107 times.
14170183 if(unsigned(jumpid) >= MAXITEMS) jumpid = -1;
29663
29664
2/2
✓ Branch 0 taken 13818107 times.
✓ Branch 1 taken 352076 times.
14170183 if (jumpid != -1)
29665 {
29666 352076 itemdata const& itm = itemsbuf[jumpid];
29667
29668 352076 byte intbtn = byte(itm.misc2&0xFF);
29669
1/2
✓ Branch 0 taken 352076 times.
✗ Branch 1 not taken.
352076 if(getIntBtnInput(intbtn, false, true, false, false, true))
29670 return jumpid; //not pressed
29671 352076 }
29672
29673
4/4
✓ Branch 0 taken 124977 times.
✓ Branch 1 taken 14045206 times.
✓ Branch 2 taken 118917 times.
✓ Branch 3 taken 6060 times.
14170183 if((itype_rocs==getItemFamily(itemsbuf,Bwpn)) && DrunkcBbtn())
29674 6060 return Bwpn;
29675
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14164123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14164123 if((itype_rocs==getItemFamily(itemsbuf,Awpn)) && DrunkcAbtn())
29676 return Awpn;
29677
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14164123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14164123 if((itype_rocs==getItemFamily(itemsbuf,Xwpn)) && DrunkcEx1btn())
29678 return Xwpn;
29679
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14164123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14164123 if((itype_rocs==getItemFamily(itemsbuf,Ywpn)) && DrunkcEx2btn())
29680 return Ywpn;
29681
29682 14164123 return -1;
29683 14170183 }
29684
29685 bool isItmPressed(int32_t itmid)
29686 {
29687 if(itmid==(NEG_OR_MASK(Bwpn,0xFFF)) && DrunkcBbtn()) return true;
29688 if(itmid==(NEG_OR_MASK(Awpn,0xFFF)) && DrunkcAbtn()) return true;
29689 if(itmid==(NEG_OR_MASK(Xwpn,0xFFF)) && DrunkcEx1btn()) return true;
29690 if(itmid==(NEG_OR_MASK(Ywpn,0xFFF)) && DrunkcEx2btn()) return true;
29691 return false;
29692 }
29693
29694 //helper function
29695 23779 static void selectNextBTNWpn(int32_t type, word& wpos, int32_t& BTNwpn,
29696 int32_t& directItemBTN, word f1 = 255, word f2 = 255, word f3 = 255)
29697 {
29698
1/2
✓ Branch 0 taken 23779 times.
✗ Branch 1 not taken.
23779 if(!new_subscreen_active)
29699 return;
29700 23779 byte pgn = wpos&0xFF, pos = wpos>>8;
29701 23779 bool empty = pgn==255;
29702
3/4
✓ Branch 0 taken 9898 times.
✓ Branch 1 taken 13881 times.
✓ Branch 2 taken 9898 times.
✗ Branch 3 not taken.
23779 if(empty && get_qr(qr_NO_BUTTON_VERIFY)) return; //intentional nothingness
29703
2/2
✓ Branch 0 taken 9898 times.
✓ Branch 1 taken 13881 times.
23779 SubscrPage* pg = new_subscreen_active->get_page(pgn==255?new_subscreen_active->curpage:pgn);
29704
1/2
✓ Branch 0 taken 23779 times.
✗ Branch 1 not taken.
23779 if(!pg)
29705 return;
29706
4/6
✓ Branch 0 taken 22490 times.
✓ Branch 1 taken 1289 times.
✓ Branch 2 taken 1289 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1289 times.
23779 auto fp1 = ((f1&0xFF)==255) ? 255 : ((empty || (f1&0xFF)==(wpos&0xFF)) ? f1 : 255);
29707
4/6
✓ Branch 0 taken 23775 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
23779 auto fp2 = ((f2&0xFF)==255) ? 255 : ((empty || (f2&0xFF)==(wpos&0xFF)) ? f2 : 255);
29708
4/6
✓ Branch 0 taken 23775 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
23779 auto fp3 = ((f3&0xFF)==255) ? 255 : ((empty || (f3&0xFF)==(wpos&0xFF)) ? f3 : 255);
29709 23779 auto ret = pg->movepos_legacy(type, wpos, fp1, fp2, fp3);
29710
2/2
✓ Branch 0 taken 9898 times.
✓ Branch 1 taken 13881 times.
23779 if((ret&0xFF) == 0xFF)
29711 9898 BTNwpn = -1;
29712 13881 else BTNwpn = pg->get_item_pos(ret>>8);
29713
2/2
✓ Branch 0 taken 13881 times.
✓ Branch 1 taken 9898 times.
23779 directItemBTN = NEG_OR_MASK(BTNwpn,0xFFF);
29714 23779 wpos = ret;
29715 23779 }
29716 5585 void selectNextAWpn(int32_t type)
29717 {
29718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5585 times.
5585 if(!get_qr(qr_SELECTAWPN))
29719 return;
29720
2/4
✓ Branch 0 taken 5585 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5585 times.
5585 selectNextBTNWpn(type, game->awpn, Awpn, directItemA, COND_BWPN, COND_XWPN, COND_YWPN);
29721 5585 }
29722
29723 18194 void selectNextBWpn(int32_t type)
29724 {
29725
1/2
✓ Branch 0 taken 18194 times.
✗ Branch 1 not taken.
18194 if(!new_subscreen_active)
29726 return;
29727
6/6
✓ Branch 0 taken 12890 times.
✓ Branch 1 taken 5304 times.
✓ Branch 2 taken 18190 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 18190 times.
18194 selectNextBTNWpn(type, game->bwpn, Bwpn, directItemB, COND_AWPN, COND_XWPN, COND_YWPN);
29728 18194 }
29729
29730 void selectNextXWpn(int32_t type)
29731 {
29732 if(!get_qr(qr_SET_XBUTTON_ITEMS)) return;
29733 if(!new_subscreen_active)
29734 return;
29735 selectNextBTNWpn(type, game->xwpn, Xwpn, directItemX, COND_BWPN, COND_AWPN, COND_YWPN);
29736 }
29737
29738 void selectNextYWpn(int32_t type)
29739 {
29740 if(!get_qr(qr_SET_YBUTTON_ITEMS)) return;
29741 if(!new_subscreen_active)
29742 return;
29743 selectNextBTNWpn(type, game->ywpn, Ywpn, directItemY, COND_BWPN, COND_XWPN, COND_AWPN);
29744 }
29745
29746 //helper function
29747 31037950 static void verifyWpn(word& wpos, int32_t& BTNwpn, int32_t& directItemBTN, word f1 = 255, word f2 = 255, word f3 = 255)
29748 {
29749
2/2
✓ Branch 0 taken 31030580 times.
✓ Branch 1 taken 7370 times.
31037950 if(!new_subscreen_active)
29750 7370 return;
29751 31030580 byte pgn = wpos&0xFF, pos = wpos>>8;
29752 31030580 bool empty = pgn==255;
29753
4/4
✓ Branch 0 taken 2439557 times.
✓ Branch 1 taken 28591023 times.
✓ Branch 2 taken 903467 times.
✓ Branch 3 taken 1536090 times.
31030580 if(empty && get_qr(qr_NO_BUTTON_VERIFY)) return; //intentional nothingness
29754
2/2
✓ Branch 0 taken 903467 times.
✓ Branch 1 taken 28591023 times.
29494490 SubscrPage* pg = new_subscreen_active->get_page(pgn==255?new_subscreen_active->curpage:pgn);
29755
1/2
✓ Branch 0 taken 29494490 times.
✗ Branch 1 not taken.
29494490 if(!pg)
29756 return;
29757
5/6
✓ Branch 0 taken 22360013 times.
✓ Branch 1 taken 7134477 times.
✓ Branch 2 taken 7076711 times.
✓ Branch 3 taken 57766 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7076711 times.
29494490 auto fp1 = ((f1&0xFF)==255) ? 255 : ((empty || (f1&0xFF)==(wpos&0xFF)) ? f1 : 255);
29758
5/6
✓ Branch 0 taken 24072161 times.
✓ Branch 1 taken 5422329 times.
✓ Branch 2 taken 5422289 times.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5422289 times.
29494490 auto fp2 = ((f2&0xFF)==255) ? 255 : ((empty || (f2&0xFF)==(wpos&0xFF)) ? f2 : 255);
29759
5/6
✓ Branch 0 taken 24875462 times.
✓ Branch 1 taken 4619028 times.
✓ Branch 2 taken 4618990 times.
✓ Branch 3 taken 38 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4618990 times.
29494490 auto fp3 = ((f3&0xFF)==255) ? 255 : ((empty || (f3&0xFF)==(wpos&0xFF)) ? f3 : 255);
29760 29494490 wpos = pg->movepos_legacy(SEL_VERIFY_RIGHT, wpos, fp1, fp2, fp3);
29761
2/2
✓ Branch 0 taken 903395 times.
✓ Branch 1 taken 28591095 times.
29494490 if((wpos&0xFF) == 0xFF)
29762 903395 BTNwpn = -1;
29763 28591095 else BTNwpn = pg->get_item_pos(wpos>>8);
29764
2/2
✓ Branch 0 taken 28328210 times.
✓ Branch 1 taken 1166280 times.
29494490 directItemBTN = NEG_OR_MASK(BTNwpn,0xFFF);
29765 31037950 }
29766
29767 23872415 void verifyAWpn()
29768 {
29769
2/2
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 23871396 times.
23872415 if (game->forced_awpn != -1)
29770 1019 return;
29771
2/2
✓ Branch 0 taken 1419315 times.
✓ Branch 1 taken 22452081 times.
23871396 if(!get_qr(qr_SELECTAWPN))
29772 {
29773 22452081 Awpn = selectSword();
29774 22452081 game->awpn = 255;
29775 22452081 }
29776 else
29777 {
29778
4/4
✓ Branch 0 taken 873805 times.
✓ Branch 1 taken 545510 times.
✓ Branch 2 taken 545510 times.
✓ Branch 3 taken 873805 times.
1419315 verifyWpn(game->awpn, Awpn, directItemA, COND_BWPN, COND_XWPN, COND_YWPN);
29779 }
29780 23872415 }
29781
29782 23866110 void verifyBWpn()
29783 {
29784
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 23865097 times.
23866110 if (game->forced_bwpn != -1)
29785 1013 return;
29786
6/6
✓ Branch 0 taken 1418494 times.
✓ Branch 1 taken 22446603 times.
✓ Branch 2 taken 2876769 times.
✓ Branch 3 taken 20988328 times.
✓ Branch 4 taken 2876769 times.
✓ Branch 5 taken 20988328 times.
23865097 verifyWpn(game->bwpn, Bwpn, directItemB, COND_AWPN, COND_XWPN, COND_YWPN);
29787 23866110 }
29788
29789 23866110 void verifyXWpn()
29790 {
29791
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 23865097 times.
23866110 if (game->forced_xwpn != -1)
29792 1013 return;
29793
2/2
✓ Branch 0 taken 2876769 times.
✓ Branch 1 taken 20988328 times.
23865097 if(!get_qr(qr_SET_XBUTTON_ITEMS))
29794 20988328 return;
29795
3/4
✓ Branch 0 taken 2331951 times.
✓ Branch 1 taken 544818 times.
✓ Branch 2 taken 2876769 times.
✗ Branch 3 not taken.
2876769 verifyWpn(game->xwpn, Xwpn, directItemX, COND_BWPN, COND_AWPN, COND_YWPN);
29796 23866110 }
29797
29798 23866110 void verifyYWpn()
29799 {
29800
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 23865097 times.
23866110 if (game->forced_ywpn != -1)
29801 1013 return;
29802
2/2
✓ Branch 0 taken 2876769 times.
✓ Branch 1 taken 20988328 times.
23865097 if(!get_qr(qr_SET_YBUTTON_ITEMS))
29803 20988328 return;
29804
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2876769 times.
✓ Branch 2 taken 544818 times.
✓ Branch 3 taken 2331951 times.
2876769 verifyWpn(game->ywpn, Ywpn, directItemY, COND_BWPN, COND_XWPN, COND_AWPN);
29805 23866110 }
29806
29807 23866110 void verifyBothWeapons()
29808 {
29809 23866110 verifyAWpn();
29810 23866110 verifyBWpn();
29811 23866110 verifyXWpn();
29812 23866110 verifyYWpn();
29813 23866110 }
29814
29815 // Select the sword for the A button if the 'select A button weapon' quest rule isn't set.
29816 22452440 int32_t selectSword()
29817 {
29818 22452440 return current_item_id(itype_sword);
29819 }
29820
29821 // Adding code here for allowing hardcoding a button to a specific itemclass.
29822 int32_t selectItemclass(int32_t itemclass)
29823 {
29824 int32_t ret = current_item_id(itemclass);
29825
29826 if(ret == -1)
29827 ret = 0;
29828
29829 return ret;
29830 }
29831
29832 // Used for the 'Pickup Hearts' item pickup condition.
29833 302 bool canget(int32_t id)
29834 {
29835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 302 times.
302 return id>=0 && (game->get_maxlife()>=(itemsbuf[id].pickup_hearts*game->get_hp_per_heart()));
29836 }
29837
29838 63 void dospecialmoney(int32_t index)
29839 {
29840 63 int32_t tmp=currscr>=128?1:0;
29841 63 int32_t priceindex = ((item*)items.spr(index))->PriceIndex;
29842
29843
4/7
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
63 switch(tmpscr[tmp].room)
29844 {
29845 case rINFO: // pay for info
29846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(prices[priceindex]!=100000 ) // 100000 is a placeholder price for free items
29847 {
29848
29849
29850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!current_item_power(itype_wallet))
29851 {
29852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (game->get_spendable_rupies() < abs(prices[priceindex]))
29853 return;
29854 16 int32_t tmpprice = -abs(prices[priceindex]);
29855 16 int32_t total = game->get_drupy()-tmpprice;
29856 16 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29857 16 game->set_drupy(game->get_drupy()-total);
29858 //game->change_drupy(-abs(prices[priceindex]));
29859 16 }
29860
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( current_item_power(itype_wallet)>0 )
29861 {
29862 game->change_drupy(0);
29863 }
29864 16 }
29865 16 rectfill(msg_bg_display_buf, 0, 0, msg_bg_display_buf->w, 80, 0);
29866 16 rectfill(msg_txt_display_buf, 0, 0, msg_txt_display_buf->w, 80, 0);
29867 16 donewmsg(QMisc.info[tmpscr[tmp].catchall].str[priceindex]);
29868 16 clear_bitmap(pricesdisplaybuf);
29869 16 set_clip_state(pricesdisplaybuf, 1);
29870 16 items.del(0);
29871
29872
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 for(int32_t i=0; i<items.Count(); i++)
29873 48 ((item*)items.spr(i))->pickup=ipDUMMY;
29874
29875 // Prevent the prices from being displayed anymore
29876
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 for(int32_t i=0; i<3; i++)
29877 {
29878 48 prices[i] = 0;
29879 48 }
29880
29881 16 break;
29882
29883 case rMONEY: // secret money
29884 {
29885 20 ((item*)items.spr(0))->pickup = ipDUMMY;
29886
29887 20 prices[0] = tmpscr[tmp].catchall;
29888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (!current_item_power(itype_wallet))
29889 20 game->change_drupy(prices[0]);
29890 //game->set_drupy(game->get_drupy()+price); may be needed everywhere
29891
29892 20 putprices(false);
29893
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
20 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
29894 20 break;
29895 }
29896
29897 case rGAMBLE: // gamble
29898 {
29899 if(game->get_spendable_rupies()<10 && !current_item_power(itype_wallet)) return; //Why 10?
29900
29901 unsigned si=(zc_oldrand()%24)*3;
29902
29903 for(int32_t i=0; i<3; i++)
29904 prices[i]=gambledat[si++];
29905
29906 game->set_drupy(game->get_drupy()+prices[priceindex]);
29907 putprices(true);
29908
29909 for(int32_t i=1; i<4; i++)
29910 ((item*)items.spr(i))->pickup=ipDUMMY;
29911 }
29912 break;
29913
29914 case rBOMBS:
29915 {
29916
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
29917 return;
29918
29919 15 int32_t price = -tmpscr[tmp].catchall;
29920 15 int32_t wmedal = current_item_id(itype_wealthmedal);
29921
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(wmedal >= 0)
29922 {
29923 if(itemsbuf[wmedal].flags & item_flag1)
29924 price*=(itemsbuf[wmedal].misc1/100.0);
29925 else
29926 price+=itemsbuf[wmedal].misc1;
29927 }
29928
29929 15 int32_t total = game->get_drupy()-price;
29930 15 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29931 15 game->set_drupy(game->get_drupy()-total);
29932 //game->set_drupy(game->get_drupy()+price);
29933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
29934 15 game->change_maxbombs(4);
29935 15 game->set_bombs(game->get_maxbombs());
29936 {
29937 15 int32_t div = zinit.bomb_ratio;
29938
29939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(div > 0)
29940 15 game->change_maxcounter(4/div, 6);
29941 }
29942
29943 //also give Hero an actual Bomb item
29944
2/2
✓ Branch 0 taken 3840 times.
✓ Branch 1 taken 15 times.
3855 for(int32_t i=0; i<MAXITEMS; i++)
29945 {
29946
4/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 3823 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 15 times.
3840 if(itemsbuf[i].family == itype_bomb && itemsbuf[i].fam_type == 1)
29947 15 getitem(i, true, true);
29948 3840 }
29949
29950 15 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
29951 15 fadeclk=66;
29952 15 dismissmsg();
29953 15 clear_bitmap(pricesdisplaybuf);
29954 15 set_clip_state(pricesdisplaybuf, 1);
29955 15 verifyBothWeapons();
29956 15 break;
29957 }
29958
29959 case rARROWS:
29960 {
29961 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
29962 return;
29963
29964 int32_t price = -tmpscr[tmp].catchall;
29965 int32_t wmedal = current_item_id(itype_wealthmedal);
29966 if(wmedal >= 0)
29967 {
29968 if(itemsbuf[wmedal].flags & item_flag1)
29969 price*=(itemsbuf[wmedal].misc1/100.0);
29970 else
29971 price+=itemsbuf[wmedal].misc1;
29972 }
29973
29974 int32_t total = game->get_drupy()-price;
29975 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29976 game->set_drupy(game->get_drupy()-total);
29977
29978 //game->set_drupy(game->get_drupy()+price);
29979 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
29980 game->change_maxarrows(10);
29981 game->set_arrows(game->get_maxarrows());
29982 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
29983 fadeclk=66;
29984 dismissmsg();
29985 clear_bitmap(pricesdisplaybuf);
29986 set_clip_state(pricesdisplaybuf, 1);
29987 verifyBothWeapons();
29988 break;
29989 }
29990
29991 case rSWINDLE:
29992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(items.spr(index)->id==iRupy)
29993 {
29994
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
29995 return;
29996 12 int32_t tmpprice = -tmpscr[tmp].catchall;
29997 12 int32_t total = game->get_drupy()-tmpprice;
29998 12 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29999 12 game->set_drupy(game->get_drupy()-total);
30000 12 }
30001 else
30002 {
30003 if(game->get_maxlife()<=game->get_hp_per_heart())
30004 return;
30005
30006 game->set_life(zc_max(game->get_life()-game->get_hp_per_heart(),0));
30007 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),(game->get_hp_per_heart())));
30008 }
30009
30010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
30011 12 ((item*)items.spr(0))->pickup=ipDUMMY+ipFADE;
30012 12 ((item*)items.spr(1))->pickup=ipDUMMY+ipFADE;
30013 12 fadeclk=66;
30014 12 dismissmsg();
30015 12 clear_bitmap(pricesdisplaybuf);
30016 12 set_clip_state(pricesdisplaybuf, 1);
30017 12 break;
30018 }
30019 63 }
30020
30021 21858 void getitem(int32_t id, bool nosound, bool doRunPassive)
30022 {
30023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21858 times.
21858 if(unsigned(id) >= MAXITEMS)
30024 return;
30025
30026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21858 times.
21858 if (replay_is_active())
30027
1/2
✓ Branch 0 taken 21858 times.
✗ Branch 1 not taken.
21858 replay_step_comment(fmt::format("getitem {}", item_string[id]));
30028
30029
2/2
✓ Branch 0 taken 21378 times.
✓ Branch 1 taken 480 times.
21858 if(get_qr(qr_SCC_ITEM_COMBINES_ITEMS))
30030 {
30031 480 int32_t nextitem = -1;
30032 480 do
30033 {
30034 480 nextitem = -1;
30035
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
480 if((itemsbuf[id].flags & item_combine) && game->get_item(id))
30036 // Item upgrade routine.
30037 {
30038
30039 for(int32_t i=0; i<MAXITEMS; i++)
30040 {
30041 // Find the item which is as close to this item's fam_type as possible.
30042 if(itemsbuf[i].family==itemsbuf[id].family && itemsbuf[i].fam_type>itemsbuf[id].fam_type
30043 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
30044 {
30045 nextitem = i;
30046 }
30047 }
30048
30049 if(nextitem>-1)
30050 {
30051 id = nextitem;
30052 if(!get_qr(qr_ITEMCOMBINE_CONTINUOUS))
30053 break; //no looping
30054 }
30055 }
30056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 } while(nextitem > -1);
30057 480 }
30058
30059 21858 itemdata const& idat = itemsbuf[id&0xFF];
30060
30061 43716 bool equipment = idat.flags &
30062 21858 ((idat.family == itype_triforcepiece) ? item_flag8 : item_gamedata);
30063
30064
2/2
✓ Branch 0 taken 19819 times.
✓ Branch 1 taken 2039 times.
21858 if(equipment)
30065 {
30066 // Fix boomerang sounds.
30067 2039 int32_t itemid = current_item_id(idat.family);
30068
30069
4/6
✓ Branch 0 taken 1112 times.
✓ Branch 1 taken 927 times.
✓ Branch 2 taken 1093 times.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2039 if(itemid>=0 && (idat.family == itype_brang || idat.family == itype_divineprotection
30070
5/6
✓ Branch 0 taken 1093 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1091 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1090 times.
✓ Branch 5 taken 1 times.
1093 || idat.family == itype_hookshot || idat.family == itype_switchhook || idat.family == itype_cbyrna)
30071 1112 && sfx_allocated(itemsbuf[itemid].usesound)
30072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1112 times.
1112 && idat.usesound != itemsbuf[itemid].usesound)
30073 {
30074 stop_sfx(itemsbuf[itemid].usesound);
30075 cont_sfx(idat.usesound);
30076 }
30077
30078 2039 int32_t curitm = current_item_id(idat.family);
30079
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
2039 if(!get_qr(qr_KEEPOLD_APPLIES_RETROACTIVELY)
30080
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2039 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2039 || curitm < 0 || (itemsbuf[curitm].fam_type <= idat.fam_type)
30081 || (itemsbuf[curitm].flags & item_keep_old))
30082 {
30083 2039 game->set_item(id,true);
30084 2039 passiveitem_script(id, doRunPassive);
30085 2039 }
30086
30087
2/2
✓ Branch 0 taken 746 times.
✓ Branch 1 taken 1293 times.
2039 if(!(idat.flags & item_keep_old))
30088 {
30089
4/4
✓ Branch 0 taken 1125 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 1090 times.
1293 if(!get_qr(qr_BROKEN_KEEPOLD_FLAG) || current_item(idat.family)<idat.fam_type)
30090 {
30091 203 removeLowerLevelItemsOfFamily(game,itemsbuf,idat.family, idat.fam_type);
30092 203 }
30093 1293 }
30094
30095 // NES consistency: replace all flying boomerangs with the current boomerang.
30096
2/2
✓ Branch 0 taken 1985 times.
✓ Branch 1 taken 54 times.
2039 if(idat.family==itype_brang)
30097
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 54 times.
55 for(int32_t i=0; i<Lwpns.Count(); i++)
30098 {
30099 1 weapon *w = ((weapon*)Lwpns.spr(i));
30100
30101
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(w->id==wBrang)
30102 {
30103 w->LOADGFX(idat.wpn);
30104 }
30105 55 }
30106 2039 }
30107
30108
2/2
✓ Branch 0 taken 2951 times.
✓ Branch 1 taken 18907 times.
21858 if(idat.count!=-1)
30109 {
30110
2/2
✓ Branch 0 taken 18466 times.
✓ Branch 1 taken 441 times.
18907 if(idat.setmax)
30111 {
30112 // Bomb bags are a special case; they may be set not to increase super bombs
30113
5/6
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 422 times.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 3 times.
441 if(idat.family==itype_bombbag && idat.count==2 && (idat.flags&16)==0)
30114 {
30115 3 int32_t max = game->get_maxbombs();
30116
30117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(max<idat.max) max=idat.max;
30118
30119
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 game->set_maxbombs(zc_min(game->get_maxbombs()+idat.setmax,max), false);
30120 3 }
30121 else
30122 {
30123 438 int32_t max = game->get_maxcounter(idat.count);
30124
30125
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 353 times.
438 if(max<idat.max) max=idat.max;
30126
30127
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 156 times.
438 game->set_maxcounter(zc_min(game->get_maxcounter(idat.count)+idat.setmax,max), idat.count);
30128 }
30129 441 }
30130
30131 // Amount is an uint16_t, but the range is -9999 to 16383
30132 // -1 is actually 16385 ... -9999 is 26383, and 0x8000 means use the drain counter
30133
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 18610 times.
18907 if(idat.amount&0x3FFF)
30134 {
30135
2/2
✓ Branch 0 taken 10743 times.
✓ Branch 1 taken 7867 times.
18610 if(idat.amount&0x8000)
30136 21486 game->set_dcounter(
30137
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10742 times.
10743 game->get_dcounter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
30138 else
30139 {
30140
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7867 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7867 if(idat.amount>=16385 && game->get_counter(0)<=idat.amount-16384)
30141 game->set_counter(0, idat.count);
30142 else
30143 // This is too confusing to try and change...
30144
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7867 times.
✓ Branch 2 taken 3678 times.
✓ Branch 3 taken 4189 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3678 times.
7867 game->set_counter(zc_min(game->get_counter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF),game->get_maxcounter(idat.count)), idat.count);
30145 }
30146 18610 }
30147 18907 }
30148
30149
4/4
✓ Branch 0 taken 21823 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 573 times.
✓ Branch 3 taken 21250 times.
21858 if(idat.playsound&&!nosound)
30150 {
30151 21250 sfx(idat.playsound);
30152 21250 }
30153
30154 //add lower-level items
30155
2/2
✓ Branch 0 taken 21802 times.
✓ Branch 1 taken 56 times.
21858 if(idat.flags&item_gain_old)
30156 {
30157
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 56 times.
99 for(int32_t i=idat.fam_type-1; i>0; i--)
30158 {
30159 43 int32_t potid = getItemID(itemsbuf, idat.family, i);
30160
30161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(potid != -1)
30162 {
30163 43 game->set_item(potid, true);
30164 43 }
30165 43 }
30166 56 }
30167
30168
12/14
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 20078 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 475 times.
✓ Branch 6 taken 126 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 100 times.
✓ Branch 9 taken 89 times.
✓ Branch 10 taken 72 times.
✓ Branch 11 taken 722 times.
✓ Branch 12 taken 119 times.
✓ Branch 13 taken 24 times.
21858 switch(idat.family)
30169 {
30170 case itype_itmbundle:
30171 {
30172 18 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
30173 15 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
30174 3 bool pscript = (idat.flags & item_flag1);
30175
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 3 times.
33 for(auto q = 0; q < 10; ++q)
30176 {
30177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(unsigned(ids[q]) >= MAXITEMS) continue;
30178
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 10 times.
30 if(pscript)
30179 10 collectitem_script(ids[q]);
30180 30 getitem(ids[q], true, true);
30181 30 }
30182 }
30183 3 break;
30184
30185 case itype_progressive_itm:
30186 {
30187 int32_t newid = get_progressive_item(idat);
30188 if(newid > -1)
30189 getitem(newid, nosound, true);
30190 }
30191 break;
30192
30193 case itype_bottlefill:
30194 {
30195 if(idat.misc1)
30196 {
30197 game->fillBottle(idat.misc1);
30198 }
30199 }
30200 break;
30201
30202 case itype_clock:
30203 {
30204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if(idat.flags & item_flag1) //Active use, not passive
30205 break;
30206
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
475 if((idat.flags & item_flag2) && clockclk) //"Can't activate while clock active"
30207 break;
30208 475 setClock(watch=true);
30209
30210
2/2
✓ Branch 0 taken 243200 times.
✓ Branch 1 taken 475 times.
243675 for(int32_t i=0; i<eMAXGUYS; i++)
30211 243200 clock_zoras[i]=0;
30212
30213 475 clockclk=itemsbuf[id&0xFF].misc1;
30214 475 sfx(idat.usesound);
30215 }
30216 475 break;
30217
30218 case itype_lkey:
30219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(game->lvlkeys[dlevel]<255) game->lvlkeys[dlevel]++;
30220 126 break;
30221
30222 case itype_ring:
30223 case itype_magicring:
30224
6/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 2 times.
45 if((get_qr(qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
30225 {
30226 43 ringcolor(false);
30227 43 }
30228 45 break;
30229
30230 case itype_whispring:
30231 {
30232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(idat.flags & item_flag1)
30233 {
30234
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(HeroSwordClk()==-1) setSwordClk(150); // Let's not bother applying the divisor.
30235
30236
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(HeroItemClk()==-1) setItemClk(150); // Let's not bother applying the divisor.
30237
30238
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(HeroItemClk()== 1) setShieldClk(150); // Let's not bother applying the divisor.
30239 5 }
30240
30241
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if(idat.power==0)
30242 {
30243 2 setSwordClk(0);
30244 2 setItemClk(0);
30245 2 setShieldClk(0);
30246 2 }
30247
30248 5 break;
30249 }
30250
30251
30252 case itype_map:
30253 100 game->lvlitems[dlevel]|=liMAP;
30254 100 break;
30255
30256 case itype_compass:
30257 89 game->lvlitems[dlevel]|=liCOMPASS;
30258 89 break;
30259
30260 case itype_bosskey:
30261 72 game->lvlitems[dlevel]|=liBOSSKEY;
30262 72 break;
30263
30264 case itype_fairy:
30265
30266
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 722 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 517 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 205 times.
722 game->set_life(zc_min(game->get_life()+(idat.flags&item_flag1 ?(int32_t)(game->get_maxlife()*(idat.misc1/100.0)):((idat.misc1*game->get_hp_per_heart()))),game->get_maxlife()));
30267
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 722 times.
✓ Branch 2 taken 115 times.
✓ Branch 3 taken 607 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 115 times.
722 game->set_magic(zc_min(game->get_magic()+(idat.flags&item_flag2 ?(int32_t)(game->get_maxmagic()*(idat.misc2/100.0)):((idat.misc2*game->get_mp_per_block()))),game->get_maxmagic()));
30268 722 break;
30269
30270 case itype_heartpiece:
30271 119 game->change_HCpieces(1);
30272
30273
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 26 times.
119 if(game->get_HCpieces()<game->get_hcp_per_hc())
30274 93 break;
30275
30276 26 game->set_HCpieces(0);
30277
30278 26 getitem(heart_container_id());
30279 26 break;
30280
30281 case itype_killem:
30282 {
30283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(idat.flags & item_flag1) //Active use, not passive
30284 break;
30285 24 kill_em_all();
30286 24 sfx(idat.usesound);
30287 }
30288 24 break;
30289 }
30290
30291 21858 flushItemCache();
30292 21858 update_subscreens();
30293 21858 refresh_subscr_items();
30294 21858 verifyBothWeapons();
30295 21858 }
30296
30297 9 void takeitem(int32_t id)
30298 {
30299 9 game->set_item(id, false);
30300 9 itemdata const& idat = itemsbuf[id];
30301
30302 /* Lower the counters! */
30303
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(idat.count!=-1)
30304 {
30305 if(idat.setmax)
30306 {
30307 game->set_maxcounter(game->get_maxcounter(idat.count)-idat.setmax, idat.count);
30308 }
30309
30310 if(idat.amount&0x3FFF)
30311 {
30312 if(idat.amount&0x8000)
30313 game->set_dcounter(game->get_dcounter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
30314 else game->set_counter(game->get_counter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
30315 }
30316 }
30317
30318
1/10
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9 switch(itemsbuf[id&0xFF].family)
30319 {
30320 // NES consistency: replace all flying boomerangs with the current boomerang.
30321 case itype_brang:
30322 if(current_item(itype_brang)) for(int32_t i=0; i<Lwpns.Count(); i++)
30323 {
30324 weapon *w = ((weapon*)Lwpns.spr(i));
30325
30326 if(w->id==wBrang)
30327 {
30328 w->LOADGFX(itemsbuf[current_item_id(itype_brang)].wpn);
30329 }
30330 }
30331
30332 break;
30333
30334 case itype_itmbundle:
30335 {
30336 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
30337 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
30338 for(auto q = 0; q < 10; ++q)
30339 {
30340 if(unsigned(ids[q]) >= MAXITEMS) continue;
30341 takeitem(ids[q]);
30342 }
30343 }
30344 break;
30345
30346 case itype_progressive_itm:
30347 {
30348 int32_t newid = get_progressive_item(idat, true);
30349 if(newid > -1)
30350 takeitem(newid);
30351 }
30352 break;
30353
30354 case itype_heartpiece:
30355 if(game->get_maxlife()>game->get_hp_per_heart())
30356 {
30357 if(game->get_HCpieces()==0)
30358 {
30359 game->set_HCpieces(game->get_hcp_per_hc());
30360 takeitem(iHeartC);
30361 }
30362
30363 game->change_HCpieces(-1);
30364 }
30365 break;
30366
30367 case itype_map:
30368 game->lvlitems[dlevel]&=~liMAP;
30369 break;
30370
30371 case itype_compass:
30372 game->lvlitems[dlevel]&=~liCOMPASS;
30373 break;
30374
30375 case itype_bosskey:
30376 game->lvlitems[dlevel]&=~liBOSSKEY;
30377 break;
30378
30379 case itype_lkey:
30380 if(game->lvlkeys[dlevel]) game->lvlkeys[dlevel]--;
30381 break;
30382
30383 case itype_ring:
30384 if((get_qr(qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
30385 {
30386 ringcolor(false);
30387 }
30388 break;
30389 }
30390 9 }
30391
30392 14127 void post_item_collect()
30393 {
30394 14127 std::vector<int32_t> &ev = FFCore.eventData;
30395 14127 ev.clear();
30396
30397 14127 throwGenScriptEvent(GENSCR_EVENT_POST_COLLECT_ITEM);
30398 14127 }
30399
30400 14344 void HeroClass::handle_triforce(int32_t id)
30401 {
30402
1/2
✓ Branch 0 taken 14344 times.
✗ Branch 1 not taken.
14344 if(unsigned(id) >= MAXITEMS)
30403 return;
30404 14344 itemdata const& itm = itemsbuf[id];
30405
3/3
✓ Branch 0 taken 14226 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 115 times.
14344 switch(itm.family)
30406 {
30407 case itype_itmbundle:
30408 {
30409 18 int ids[10] = {itm.misc1, itm.misc2, itm.misc3, itm.misc4, itm.misc5,
30410 15 itm.misc6, itm.misc7, itm.misc8, itm.misc9, itm.misc10};
30411
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 3 times.
33 for(auto q = 0; q < 10; ++q)
30412 {
30413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(unsigned(ids[q]) >= MAXITEMS) continue;
30414 30 handle_triforce(ids[q]);
30415 30 }
30416 }
30417 3 break;
30418 case itype_triforcepiece:
30419 {
30420
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 100 times.
115 if(itm.misc2>0)
30421 100 getTriforce(id); //small
30422 15 else getBigTri(id); //big
30423 }
30424 115 break;
30425 }
30426 14344 }
30427
30428 // Attempt to pick up an item. (-1 = check items touching Hero.)
30429 14147866 void HeroClass::checkitems(int32_t index)
30430 {
30431 14147866 int32_t tmp=currscr>=128?1:0;
30432
30433
2/2
✓ Branch 0 taken 1828 times.
✓ Branch 1 taken 14146038 times.
14147866 if(index==-1)
30434 {
30435
2/2
✓ Branch 0 taken 2986530 times.
✓ Branch 1 taken 14146038 times.
17132568 for(auto ind = items.Count()-1; ind >= 0; --ind)
30436 {
30437 2986530 item* itm = (item*)items.spr(ind);
30438
2/2
✓ Branch 0 taken 2986481 times.
✓ Branch 1 taken 49 times.
2986530 if(itm->get_forcegrab())
30439 {
30440 49 checkitems(ind);
30441 49 }
30442 2986530 }
30443
2/2
✓ Branch 0 taken 4410902 times.
✓ Branch 1 taken 9735136 times.
14146038 if(diagonalMovement)
30444 {
30445 4410902 index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,6,6,1);
30446 4410902 }
30447 9735136 else index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,1,1,1);
30448 14146038 }
30449
30450
2/2
✓ Branch 0 taken 119655 times.
✓ Branch 1 taken 14028211 times.
14147866 if(index==-1)
30451 14028211 return;
30452
30453 // if (tmpscr[tmp].room==rSHOP && boughtsomething==true)
30454 // return;
30455 119655 item* ptr = (item*)items.spr(index);
30456 119655 int32_t pickup = ptr->pickup;
30457 119655 int8_t exstate = ptr->pickupexstate;
30458 119655 int32_t PriceIndex = ptr->PriceIndex;
30459 119655 int32_t id2 = ptr->id;
30460 119655 int32_t holdid = ptr->id;
30461 119655 int32_t pstr = ptr->pstring;
30462 119655 int32_t pstr_flags = ptr->pickup_string_flags;
30463 119655 int32_t linked_parent = ptr->linked_parent;
30464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119655 times.
119655 if(ptr->fallclk > 0) return; //Don't pick up a falling item
30465
30466
1/2
✓ Branch 0 taken 119655 times.
✗ Branch 1 not taken.
119655 if(itemsbuf[id2].family == itype_progressive_itm)
30467 {
30468 int32_t newid = get_progressive_item(itemsbuf[id2]);
30469 if(newid > -1)
30470 {
30471 id2 = newid;
30472 holdid = newid;
30473 pstr = itemsbuf[newid].pstring;
30474 pstr_flags = itemsbuf[newid].pickup_string_flags;
30475 }
30476 }
30477
30478
2/2
✓ Branch 0 taken 118631 times.
✓ Branch 1 taken 1024 times.
119655 bool bottledummy = (pickup&ipCHECK) && tmpscr[tmp].room == rBOTTLESHOP;
30479
30480
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 119630 times.
119655 if(bottledummy) //Dummy bullshit!
30481 {
30482
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!game->canFillBottle())
30483 return;
30484
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
30485 {
30486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!current_item_power(itype_wallet))
30487 {
30488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
30489 1 int32_t tmpprice = -abs(prices[PriceIndex]);
30490 //game->change_drupy(-abs(prices[priceindex]));
30491 1 int32_t total = game->get_drupy()-tmpprice;
30492 1 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
30493 1 game->set_drupy(game->get_drupy()-total);
30494 1 }
30495 else //infinite wallet
30496 {
30497 game->change_drupy(0);
30498 }
30499 1 }
30500 25 boughtsomething=true;
30501 //make the other shop items untouchable after
30502 //you buy something
30503
30504
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 25 times.
29 for(int32_t i=0; i<items.Count(); i++)
30505 {
30506
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
4 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
30507 2 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
30508 4 }
30509
30510 25 int32_t slot = game->fillBottle(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[PriceIndex]);
30511 25 id2 = find_bottle_for_slot(slot);
30512 25 ptr->id = id2;
30513 25 holdid = id2;
30514 25 pstr = 0;
30515 25 pickup |= ipHOLDUP;
30516 25 }
30517 else
30518 {
30519
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119630 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119630 if(itemsbuf[id2].family == itype_bottlefill && !game->canFillBottle())
30520 return; //No picking these up unless you have a bottle to fill!
30521
30522
5/6
✓ Branch 0 taken 114421 times.
✓ Branch 1 taken 5209 times.
✓ Branch 2 taken 103063 times.
✓ Branch 3 taken 11358 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 103063 times.
119630 if(((pickup&ipTIMER) && (ptr->clk2 < 32))&& !(pickup & ipCANGRAB))
30523
2/2
✓ Branch 0 taken 102858 times.
✓ Branch 1 taken 205 times.
103063 if(ptr->id!=iFairyMoving)
30524 // wait for it to stop flashing, doesn't check for other items yet
30525 102858 return;
30526
30527
2/2
✓ Branch 0 taken 16717 times.
✓ Branch 1 taken 55 times.
16772 if(pickup&ipENEMY) // item was being carried by enemy
30528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
110 if(more_carried_items()<=1) // 1 includes this own item.
30529 55 hasitem &= ~2;
30530
30531
2/2
✓ Branch 0 taken 1703 times.
✓ Branch 1 taken 15069 times.
16772 if(pickup&ipDUMMY) // dummy item (usually a rupee)
30532 {
30533
2/2
✓ Branch 0 taken 1640 times.
✓ Branch 1 taken 63 times.
1703 if(pickup&ipMONEY)
30534 63 dospecialmoney(index);
30535
30536 1703 return;
30537 }
30538
30539
3/4
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 14974 times.
✓ Branch 2 taken 95 times.
✗ Branch 3 not taken.
15069 if(get_qr(qr_HEARTSREQUIREDFIX) && !canget(id2))
30540 return;
30541
30542 15069 int32_t nextitem = -1;
30543 15069 do
30544 {
30545 15069 nextitem = -1;
30546
4/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 15044 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 14 times.
15069 if((itemsbuf[id2].flags & item_combine) && game->get_item(id2))
30547 // Item upgrade routine.
30548 {
30549
30550
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 14 times.
3598 for(int32_t i=0; i<MAXITEMS; i++)
30551 {
30552 // Find the item which is as close to this item's fam_type as possible.
30553
4/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 3553 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 14 times.
3584 if(itemsbuf[i].family==itemsbuf[id2].family && itemsbuf[i].fam_type>itemsbuf[id2].fam_type
30554
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
31 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
30555 {
30556 14 nextitem = i;
30557 14 }
30558 3584 }
30559
30560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(nextitem>-1)
30561 {
30562 14 id2 = nextitem;
30563
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(get_qr(qr_ITEMCOMBINE_NEW_PSTR))
30564 {
30565 pstr = itemsbuf[id2].pstring;
30566 pstr_flags = itemsbuf[id2].pickup_string_flags;
30567 }
30568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!get_qr(qr_ITEMCOMBINE_CONTINUOUS))
30569 14 break; //no looping
30570 }
30571 }
30572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15055 times.
15055 } while(nextitem > -1);
30573
30574
2/2
✓ Branch 0 taken 14046 times.
✓ Branch 1 taken 1023 times.
15069 if(pickup&ipCHECK) // check restrictions
30575
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 709 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 107 times.
1023 switch(tmpscr[tmp].room)
30576 {
30577 case rSP_ITEM: // special item
30578
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 63 times.
207 if(!canget(id2)) // These ones always need the Hearts Required check
30579 63 return;
30580
30581 144 break;
30582
30583 case rP_SHOP: // potion shop
30584
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 14 times.
107 if(msg_active)
30585 93 return;
30586 [[fallthrough]];
30587 case rSHOP: // shop
30588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 723 times.
723 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
30589 {
30590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 723 times.
723 if(!current_item_power(itype_wallet))
30591 {
30592
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 123 times.
723 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
30593 123 int32_t tmpprice = -abs(prices[PriceIndex]);
30594 //game->change_drupy(-abs(prices[priceindex]));
30595 123 int32_t total = game->get_drupy()-tmpprice;
30596 123 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
30597 123 game->set_drupy(game->get_drupy()-total);
30598 123 }
30599 else //infinite wallet
30600 {
30601 game->change_drupy(0);
30602 }
30603 123 }
30604 123 boughtsomething=true;
30605 //make the other shop items untouchable after
30606 //you buy something
30607 123 int32_t count = 0;
30608
30609
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 123 times.
492 for(int32_t i=0; i<3; i++)
30610 {
30611
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 324 times.
369 if(QMisc.shop[tmpscr[tmp].catchall].hasitem[i] != 0)
30612 {
30613 324 ++count;
30614 324 }
30615 369 }
30616
30617
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 123 times.
573 for(int32_t i=0; i<items.Count(); i++)
30618 {
30619
4/4
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 123 times.
✓ Branch 3 taken 201 times.
450 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
30620 201 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
30621 450 }
30622
30623 123 break;
30624 267 }
30625
30626 //EVENT
30627 {
30628 14313 std::vector<int32_t> &ev = FFCore.eventData;
30629 14313 ev.clear();
30630 14313 ev.push_back(id2*10000);
30631 14313 ev.push_back(pickup*10000);
30632 14313 ev.push_back(pstr*10000);
30633 14313 ev.push_back(pstr_flags*10000);
30634 14313 ev.push_back(0);
30635 14313 ev.push_back(ptr->getUID());
30636 14313 ev.push_back(GENEVT_ICTYPE_COLLECT*10000);
30637 14313 ev.push_back(0);
30638
30639 14313 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
30640 14313 bool nullify = ev[4] != 0;
30641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14313 times.
14313 if(nullify) return;
30642 14313 id2 = ev[0]/10000;
30643 14313 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
30644 14313 pstr = ev[2] / 10000;
30645 14313 pstr_flags = ev[3] / 10000;
30646 }
30647
30648
2/2
✓ Branch 0 taken 1527 times.
✓ Branch 1 taken 12786 times.
14313 if(pickup&ipONETIME) // set mITEM for one-time-only items
30649 {
30650 1527 setmapflag(mITEM);
30651
30652 //Okay so having old source files is a godsend. You wanna know why?
30653 //Because the issue here was never to so with the wrong flag being set; no it's always been setting the right flag.
30654 //The problem here is that guy rooms were always checking for getmapflag, which used to have an internal check for the default.
30655 //The default would be mITEM if currscr was under 128 (AKA not in a cave), and mSPECIALITEM if in a cave.
30656 //However, now the check just always defaults to mSPECIALITEM, which causes this bug.
30657 //This means that this section of code is no longer a bunch of eggshells, cause none of these overcomplicated compats actually solved shit lmao - Dimi
30658
30659 /*
30660 // WARNING - Item pickups are very volatile due to crazy compatability hacks, eg., supporting
30661 // broken behavior from early ZC versions. If you change things here please comment on its purpose.
30662
30663 // some old quests need picking up a screen item to also disable the BELOW flag (for hunger rooms, etc)
30664 // What is etc?! We need to check for every valid state here. ~Gleeok
30665 if(get_qr(qr_ITEMPICKUPSETSBELOW))
30666 {
30667 // Most older quests need one-time-pickups to not remove special items, etc.
30668 if(tmpscr->room==rGRUMBLE)
30669 {
30670 setmapflag(mSPECIALITEM);
30671 }
30672 }
30673 */
30674 1527 }
30675
2/2
✓ Branch 0 taken 12024 times.
✓ Branch 1 taken 762 times.
12786 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
30676
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 501 times.
762 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
30677
30678
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
14313 if(exstate > -1 && exstate < 32)
30679 {
30680 1 setxmapflag(1<<exstate);
30681 1 }
30682
30683
2/2
✓ Branch 0 taken 14312 times.
✓ Branch 1 taken 1 times.
14313 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
30684 {
30685
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
30686 1 hidden_entrance(0, true, false, -5);
30687 1 }
30688
30689 14313 collectitem_script(id2);
30690 14313 getitem(id2, ptr->noSound, true);
30691 }
30692
30693
2/2
✓ Branch 0 taken 1526 times.
✓ Branch 1 taken 12812 times.
14338 if(pickup&ipHOLDUP)
30694 {
30695 1526 attackclk=0;
30696 1526 reset_swordcharge();
30697
30698
3/4
✓ Branch 0 taken 1485 times.
✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1485 times.
1526 if(action!=swimming && !IsSideSwim())
30699 1485 reset_hookshot();
30700
30701
2/2
✓ Branch 0 taken 1181 times.
✓ Branch 1 taken 279 times.
1526 if(msg_onscreen)
30702 {
30703 279 dismissmsg();
30704 279 }
30705
30706 1460 clear_bitmap(pricesdisplaybuf);
30707
30708
7/8
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 1316 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 68 times.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 69 times.
✓ Branch 7 taken 117 times.
1494 if(get_qr(qr_OLDPICKUP) || ((tmpscr[tmp].room==rSP_ITEM || tmpscr[tmp].room==rRP_HC || tmpscr[tmp].room==rTAKEONE) && (pickup&ipONETIME2)) ||
30709
4/4
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
117 (get_qr(qr_SHOP_ITEMS_VANISH) && (tmpscr[tmp].room==rBOTTLESHOP || tmpscr[tmp].room==rSHOP) && (pickup&ipCHECK)))
30710 {
30711 1419 fadeclk=66;
30712 1419 }
30713
30714
5/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 1480 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 12 times.
1502 if(id2!=iBombs || action==swimming || get_qr(qr_BOMBHOLDFIX))
30715 {
30716 // don't hold up bombs unless swimming or the bomb hold fix quest rule is on
30717
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1473 times.
1490 if(action==swimming)
30718 {
30719 17 action=waterhold1; FFCore.setHeroAction(waterhold1);
30720 17 }
30721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1473 times.
1473 else if(IsSideSwim())
30722 {
30723 action=sidewaterhold1; FFCore.setHeroAction(sidewaterhold1);
30724 }
30725 else
30726 {
30727 1473 action=landhold1; FFCore.setHeroAction(landhold1);
30728 }
30729
30730
2/2
✓ Branch 0 taken 1142 times.
✓ Branch 1 taken 348 times.
1490 if(ptr->twohand)
30731 {
30732
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 342 times.
348 if(action==waterhold1)
30733 {
30734 6 action=waterhold2; FFCore.setHeroAction(waterhold2);
30735 6 }
30736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 342 times.
342 else if(action==sidewaterhold1)
30737 {
30738 action=sidewaterhold2; FFCore.setHeroAction(sidewaterhold2);
30739 }
30740 else
30741 {
30742 342 action=landhold2; FFCore.setHeroAction(landhold2);
30743 }
30744 348 }
30745
30746 1490 holdclk=130;
30747
30748 //restart music
30749
2/2
✓ Branch 0 taken 1381 times.
✓ Branch 1 taken 109 times.
1490 if(get_qr(qr_HOLDNOSTOPMUSIC) == 0)
30750 109 music_stop();
30751
30752 1490 holditem=holdid; // NES consistency: when combining blue potions, hold up the blue potion.
30753 1490 freeze_guys=true;
30754 //show the info string
30755
30756
30757 //if (pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || itemsbuf[index].pickup_string_flags&itemdataPSTRING_IP_HOLDUP ) ) )
30758
30759 1490 int32_t shop_pstr = 0;
30760
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 1348 times.
1490 if (PriceIndex > -1)
30761 {
30762
3/3
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 109 times.
✓ Branch 2 taken 1 times.
142 switch(tmpscr[tmp].room)
30763 {
30764 case rSHOP:
30765 109 shop_pstr = QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex];
30766 109 break;
30767 case rBOTTLESHOP:
30768 1 shop_pstr = QMisc.bottle_shop_types[tmpscr[tmp].catchall].str[PriceIndex];
30769 1 break;
30770 }
30771 142 }
30772
5/6
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1471 times.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1470 times.
1490 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
30773 {
30774
9/12
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 14 times.
20 if ( (pstr > 0 && pstr < msg_count) && ( ( ( pstr_flags&itemdataPSTRING_ALWAYS || pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_IP_HOLDUP || (!(FFCore.GetItemMessagePlayed(id2))) ) ) ) )
30775 {
30776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
30777 19 }
30778 1 else pstr = 0;
30779
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 19 times.
20 if(shop_pstr)
30780 {
30781 1 donewmsg(shop_pstr);
30782 1 enqueued_str = pstr;
30783 1 }
30784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 else if(pstr)
30785 {
30786 19 donewmsg(pstr);
30787 19 }
30788 20 }
30789
30790 1490 }
30791
30792
4/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 1398 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 4 times.
1502 if(itemsbuf[id2].family!=itype_triforcepiece || !(itemsbuf[id2].flags & item_gamedata))
30793 {
30794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1402 times.
1402 if (!ptr->noHoldSound) sfx(tmpscr[0].holdupsfx);
30795 1402 }
30796
30797 1502 ptr->set_forcegrab(false);
30798 1502 items.del(index);
30799
30800
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 1502 times.
1718 for(int32_t i=0; i<Lwpns.Count(); i++)
30801 {
30802 216 weapon *w = (weapon*)Lwpns.spr(i);
30803
30804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(w->dragging==index)
30805 {
30806 w->dragging=-1;
30807 }
30808
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 else if(w->dragging>index)
30809 {
30810 w->dragging-=1;
30811 }
30812 216 }
30813
30814 // clear up shop stuff
30815
4/4
✓ Branch 0 taken 813 times.
✓ Branch 1 taken 689 times.
✓ Branch 2 taken 690 times.
✓ Branch 3 taken 123 times.
1502 if((isdungeon()==0)&&(index!=0))
30816 {
30817
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 83 times.
123 if(boughtsomething)
30818 {
30819 83 fadeclk=66;
30820
30821
3/4
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
83 if(((item*)items.spr(0))->id == iRupy && ((item*)items.spr(0))->pickup & ipDUMMY)
30822 {
30823 80 items.del(0);
30824
30825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 for(int32_t i=0; i<Lwpns.Count(); i++)
30826 {
30827 weapon *w = (weapon*)Lwpns.spr(i);
30828
30829 if(w->dragging==0)
30830 {
30831 w->dragging=-1;
30832 }
30833 else if(w->dragging>0)
30834 {
30835 w->dragging-=1;
30836 }
30837 }
30838 80 }
30839 83 }
30840
30841
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(msg_onscreen)
30842 {
30843 dismissmsg();
30844 }
30845
30846 123 clear_bitmap(pricesdisplaybuf);
30847 123 set_clip_state(pricesdisplaybuf, 1);
30848 123 }
30849
30850 // items.del(index);
30851 1502 }
30852 else
30853 {
30854 12812 ptr->set_forcegrab(false);
30855 12812 items.del(index);
30856
30857
2/2
✓ Branch 0 taken 9164 times.
✓ Branch 1 taken 12812 times.
21976 for(int32_t i=0; i<Lwpns.Count(); i++)
30858 {
30859 9164 weapon *w = (weapon*)Lwpns.spr(i);
30860
30861
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 8674 times.
9164 if(w->dragging==index)
30862 {
30863 490 w->dragging=-1;
30864 490 }
30865
2/2
✓ Branch 0 taken 8670 times.
✓ Branch 1 taken 4 times.
8674 else if(w->dragging>index)
30866 {
30867 4 w->dragging-=1;
30868 4 }
30869 9164 }
30870
30871
2/2
✓ Branch 0 taken 12799 times.
✓ Branch 1 taken 13 times.
12812 if(msg_onscreen)
30872 {
30873 13 dismissmsg();
30874 13 }
30875
30876 //general item pickup message
30877 //show the info string
30878 //non-held
30879 //if ( pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(index))) ) ) )
30880
3/6
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 12676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12812 int32_t shop_pstr = ( tmpscr[tmp].room == rSHOP && PriceIndex>=0 && QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] > 0 ) ? QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] : 0;
30881
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12810 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12810 times.
12812 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
30882 {
30883
7/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
2 if ( (pstr > 0 && pstr < msg_count) && ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
30884 {
30885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
30886 1 }
30887 1 else pstr = 0;
30888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(shop_pstr)
30889 {
30890 donewmsg(shop_pstr);
30891 enqueued_str = pstr;
30892 }
30893
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 else if(pstr)
30894 {
30895 1 donewmsg(pstr);
30896 1 }
30897 2 }
30898
30899
30900 12812 clear_bitmap(pricesdisplaybuf);
30901 12812 set_clip_state(pricesdisplaybuf, 1);
30902 }
30903
30904
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 11 times.
14329 if(itemsbuf[id2].family==itype_triforcepiece
30905
4/4
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 14199 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 100 times.
14314 && itemsbuf[id2].misc2 <= 0 && linked_parent == eeGANON)
30906 {
30907 11 game->lvlitems[dlevel]|=liBOSS;
30908 11 }
30909 14314 handle_triforce(id2);
30910
2/2
✓ Branch 0 taken 1415 times.
✓ Branch 1 taken 12899 times.
14314 if(!holdclk)
30911 12899 post_item_collect();
30912 14147842 }
30913
30914 294 void HeroClass::StartRefill(int32_t refillWhat)
30915 {
30916
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 276 times.
294 if(FFCore.quest_format[vZelda] < 0x255)
30917 {
30918 //Yes, this isn't a QR check. This was implemented before the QRs got bumped up.
30919 //I attempted to change this check to a quest rule, but here's the issue: this affects
30920 //triforces and potions as well, not just fairy flags. This means that having a compat rule
30921 //would result in a rule that is checked by default for every tileset or quest made before
30922 //2.55, one in a place most people won't check. That means that if they were to go to use
30923 //the new potion or triforce flags for jinx curing behavior, they'd find that it doesn't work,
30924 //all because of an obscure compat rule being checked. Most peoples instincts are sadly not
30925 //"go through the compat rules and turn them all off", so this remains a version check instead
30926 //of a qr check. Don't make my mistake and waste time trying to change this in vain. -Deedee
30927 276 Start250Refill(refillWhat);
30928 276 return;
30929 }
30930
30931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(!refilling)
30932 {
30933 18 refillclk=21;
30934 18 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
30935 18 sfx(WAV_REFILL,128,true);
30936 18 refilling=refillWhat;
30937
30938
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if(refill_why>=0) // Item index
30939 {
30940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(itemsbuf[refill_why].family==itype_potion)
30941 {
30942 if(itemsbuf[refill_why].flags & item_flag3){swordclk=0;verifyAWpn();}
30943 if(itemsbuf[refill_why].flags & item_flag4)itemclk=0;
30944 if(itemsbuf[refill_why].flags & item_flag5)shieldjinxclk=0;
30945 }
30946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 else if(itemsbuf[refill_why].family==itype_triforcepiece)
30947 {
30948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(itemsbuf[refill_why].flags & item_flag3){swordclk=0;verifyAWpn();}
30949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(itemsbuf[refill_why].flags & item_flag4)itemclk=0;
30950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(itemsbuf[refill_why].flags & item_flag5)shieldjinxclk=0;
30951 9 }
30952 9 }
30953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 else if(refill_why==REFILL_FAIRY)
30954 {
30955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!get_qr(qr_NONBUBBLEFAIRIES)){swordclk=0;verifyAWpn();}
30956
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7 times.
9 if(get_qr(qr_ITEMBUBBLE))itemclk=0;
30957
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_qr(qr_SHIELDBUBBLE))shieldjinxclk=0;
30958 9 }
30959 18 }
30960 294 }
30961
30962 276 void HeroClass::Start250Refill(int32_t refillWhat)
30963 {
30964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
276 if(!refilling)
30965 {
30966 276 refillclk=21;
30967 276 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
30968 276 sfx(WAV_REFILL,128,true);
30969 276 refilling=refillWhat;
30970
30971 // For ~2 years <2.55 quests were broken, never restoring anything on fairies.
30972 // https://discord.com/channels/876899628556091432/1275805052006563861
30973
2/4
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 276 times.
276 if (replay_is_active() && replay_version_check(0, 35))
30974 {
30975
2/4
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 276 times.
✗ Branch 3 not taken.
276 std::string qst = replay_get_meta_str("qst");
30976
9/12
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 229 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 201 times.
✓ Branch 7 taken 28 times.
✓ Branch 8 taken 201 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 23 times.
✓ Branch 11 taken 178 times.
276 if (qst == "first_quest_layered.qst" || qst == "nes_remastered.qst" || qst == "demosp253.qst")
30977 98 return;
30978
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 178 times.
276 }
30979
30980
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 92 times.
178 if(refill_why>=0) // Item index
30981 {
30982
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 7 times.
86 if((itemsbuf[refill_why].family==itype_potion)&&(!get_qr(qr_NONBUBBLEMEDICINE)))
30983 {
30984 7 swordclk=0;
30985 7 verifyAWpn();
30986
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(get_qr(qr_ITEMBUBBLE)) itemclk=0;
30987 7 }
30988
30989
4/4
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 57 times.
86 if((itemsbuf[refill_why].family==itype_triforcepiece)&&(!get_qr(qr_NONBUBBLETRIFORCE)))
30990 {
30991 57 swordclk=0;
30992 57 verifyAWpn();
30993
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 1 times.
57 if(get_qr(qr_ITEMBUBBLE)) itemclk=0;
30994 57 }
30995 86 }
30996
3/4
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 54 times.
92 else if((refill_why==REFILL_FAIRY)&&(!get_qr(qr_NONBUBBLEFAIRIES)))
30997 {
30998 54 swordclk=0;
30999 54 verifyAWpn();
31000
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(get_qr(qr_ITEMBUBBLE)) itemclk=0;
31001 54 }
31002 178 }
31003 276 }
31004
31005 375620 bool HeroClass::refill()
31006 {
31007
4/4
✓ Branch 0 taken 22058 times.
✓ Branch 1 taken 353562 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 21422 times.
375620 if(refilling==REFILL_NONE || refilling==REFILL_FAIRYDONE)
31008 {
31009 354198 return false;
31010 }
31011
31012 21422 ++refillclk;
31013 21422 int32_t speed = get_qr(qr_FASTFILL) ? 6 : 22;
31014 21422 int32_t refill_heart_stop=game->get_maxlife();
31015 21422 int32_t refill_magic_stop=game->get_maxmagic();
31016
31017
4/4
✓ Branch 0 taken 10865 times.
✓ Branch 1 taken 10557 times.
✓ Branch 2 taken 4542 times.
✓ Branch 3 taken 6323 times.
21422 if(refill_why>=0 && itemsbuf[refill_why].family==itype_potion)
31018 {
31019
2/6
✓ Branch 0 taken 6323 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6323 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6323 refill_heart_stop=zc_min(potion_life+(itemsbuf[refill_why].flags & item_flag1 ?int32_t(game->get_maxlife()*(itemsbuf[refill_why].misc1 /100.0)):((itemsbuf[refill_why].misc1 *game->get_hp_per_heart()))),game->get_maxlife());
31020
2/6
✓ Branch 0 taken 6323 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6323 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6323 refill_magic_stop=zc_min(potion_magic+(itemsbuf[refill_why].flags & item_flag2 ?int32_t(game->get_maxmagic()*(itemsbuf[refill_why].misc2 /100.0)):((itemsbuf[refill_why].misc2 *game->get_mp_per_block()))),game->get_maxmagic());
31021 6323 }
31022
31023
2/2
✓ Branch 0 taken 18948 times.
✓ Branch 1 taken 2474 times.
21422 if(refillclk%speed == 0)
31024 {
31025 // game->life&=0xFFC;
31026
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1194 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1277 times.
2474 switch(refill_what)
31027 {
31028 case REFILL_LIFE:
31029
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 1139 times.
1194 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
31030
31031
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 1038 times.
1194 if(game->get_life()>=refill_heart_stop)
31032 {
31033 156 game->set_life(refill_heart_stop);
31034 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
31035
2/2
✓ Branch 0 taken 39936 times.
✓ Branch 1 taken 156 times.
40092 for ( int32_t q = 0; q < WAV_COUNT; q++ )
31036 {
31037
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 39780 times.
39936 if ( q == (int32_t)tmpscr->oceansfx ) continue;
31038
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 39779 times.
39780 if ( q == (int32_t)tmpscr->bosssfx ) continue;
31039 39779 stop_sfx(q);
31040 39779 }
31041 156 sfx(QMisc.miscsfx[sfxREFILL]);
31042 156 refilling=REFILL_NONE;
31043 156 return false;
31044 }
31045
31046 1038 break;
31047
31048 case REFILL_MAGIC:
31049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
31050
31051
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(game->get_magic()>=refill_magic_stop)
31052 {
31053 1 game->set_magic(refill_magic_stop);
31054 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
31055
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for ( int32_t q = 0; q < WAV_COUNT; q++ )
31056 {
31057
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 255 times.
256 if ( q == (int32_t)tmpscr->oceansfx ) continue;
31058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
255 if ( q == (int32_t)tmpscr->bosssfx ) continue;
31059 255 stop_sfx(q);
31060 255 }
31061 1 sfx(QMisc.miscsfx[sfxREFILL]);
31062 1 refilling=REFILL_NONE;
31063 1 return false;
31064 }
31065
31066 2 break;
31067
31068 case REFILL_ALL:
31069
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 1181 times.
1277 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
31070
2/2
✓ Branch 0 taken 1187 times.
✓ Branch 1 taken 90 times.
1277 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
31071
31072
4/4
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 1119 times.
✓ Branch 2 taken 137 times.
✓ Branch 3 taken 21 times.
1277 if((game->get_life()>=refill_heart_stop)&&(game->get_magic()>=refill_magic_stop))
31073 {
31074 137 game->set_life(refill_heart_stop);
31075 137 game->set_magic(refill_magic_stop);
31076 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
31077
2/2
✓ Branch 0 taken 35072 times.
✓ Branch 1 taken 137 times.
35209 for ( int32_t q = 0; q < WAV_COUNT; q++ )
31078 {
31079
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 34935 times.
35072 if ( q == (int32_t)tmpscr->oceansfx ) continue;
31080
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 34915 times.
34935 if ( q == (int32_t)tmpscr->bosssfx ) continue;
31081 34915 stop_sfx(q);
31082 34915 }
31083 137 sfx(QMisc.miscsfx[sfxREFILL]);
31084 137 refilling=REFILL_NONE;
31085 137 return false;
31086 }
31087
31088 1140 break;
31089 }
31090 2180 }
31091
31092 21128 return true;
31093 375620 }
31094
31095 100 void HeroClass::getTriforce(int32_t id2)
31096 {
31097
31098 PALETTE flash_pal;
31099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 int32_t refill_frame = ( (itemsbuf[id2].misc5 > 0) ? itemsbuf[id2].misc5 : 88 );
31100
31101
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 100 times.
25700 for(int32_t i=0; i<256; i++)
31102 {
31103
2/2
✓ Branch 0 taken 15616 times.
✓ Branch 1 taken 9984 times.
25600 flash_pal[i] = get_qr(qr_FADE) ? _RGB(255,255,0) : _RGB(255,255,255);
31104 25600 }
31105
31106
31107
31108 //get rid off all sprites but Hero
31109 100 guys.clear();
31110 100 items.clear();
31111 100 Ewpns.clear();
31112 100 Lwpns.clear();
31113 100 chainlinks.clear();
31114
31115 100 kill_subscr_items();
31116
31117 //decorations.clear();
31118
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 36 times.
100 if(!COOLSCROLL)
31119 {
31120 36 show_subscreen_items=false;
31121 36 }
31122
31123 100 sfx(itemsbuf[id2].playsound);
31124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if ( !(itemsbuf[id2].flags & item_flag11) ) music_stop();
31125
31126 //If item flag six is enabled, and a sound is set to attributes[2], play that sound.
31127
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if ( (itemsbuf[id2].flags & item_flag14) )
31128 {
31129 uint8_t playwav = itemsbuf[id2].misc3;
31130 sfx(playwav);
31131
31132 }
31133
31134 //itemsbuf[id2].flags & item_flag9 : Don't dismiss Messages
31135 //itemsbuf[id2].flags & item_flag10 : Cutscene interrupts action script..
31136 //itemsbuf[id2].flags & item_flag11 : Don't change music.
31137 //itemsbuf[id2].flags & item_flag12 : Run Collect Script Script On Collection
31138 //itemsbuf[id2].flags & item_flag13 : Run Action Script On Collection
31139 //itemsbuf[id2].flags & item_flag14 : Play second sound (WAV) from Attributes[2] (misc2)
31140 //itemsbuf[id2].flags & item_flag15 : No MIDI
31141
31142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!(itemsbuf[id2].flags & item_flag15)) //No MIDI flag
31143 {
31144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(itemsbuf[id2].misc1)
31145 jukebox(itemsbuf[id2].misc1+ZC_MIDI_COUNT-1);
31146 else
31147 100 try_zcmusic("zelda.nsf",qstpath,moduledata.tf_track,ZC_MIDI_TRIFORCE,get_emusic_volume());
31148 100 }
31149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(itemsbuf[id2].flags & item_gamedata)
31150 {
31151 100 game->lvlitems[dlevel]|=liTRIFORCE;
31152 100 }
31153
31154 100 int32_t f=0;
31155 100 int32_t x2=0;
31156 100 int32_t curtain_x=0;
31157 100 int32_t c=0;
31158
31159 100 do
31160 {
31161
31162
31163
1/2
✓ Branch 0 taken 52360 times.
✗ Branch 1 not taken.
52360 if ( (itemsbuf[id2].flags & item_flag13) ) //Run action script on collection.
31164 {
31165 if ( itemsbuf[id2].script )
31166 {
31167 if ( !FFCore.doscript(ScriptType::Item, id2) )
31168 {
31169 int i = id2;
31170 FFCore.reset_script_engine_data(ScriptType::Item, i);
31171 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id2].script, i);
31172 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
31173 }
31174 else
31175 {
31176 if ( !(itemsbuf[id2].flags & item_flag10) ) //Cutscene halts the script it resumes after cutscene.
31177 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id2].script, id2); //if flag is off, run the script every frame of the cutscene.
31178 }
31179 }
31180 }
31181 //if ( itemsbuf[id2].misc2 == 2 ) //No cutscene; what if people used '2' on older quests?
31182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 if ( (itemsbuf[id2].flags & item_flag12) ) //No cutscene
31183 {
31184 return;
31185 }
31186
2/2
✓ Branch 0 taken 52260 times.
✓ Branch 1 taken 100 times.
52360 if(f==40)
31187 {
31188 100 actiontype oldaction = action;
31189 100 ALLOFF((!(itemsbuf[id2].flags & item_flag9)), false);
31190 100 action=oldaction; // have to reset this flag
31191 100 FFCore.setHeroAction(oldaction);
31192 100 }
31193
31194
31195
4/4
✓ Branch 0 taken 48360 times.
✓ Branch 1 taken 4000 times.
✓ Branch 2 taken 43560 times.
✓ Branch 3 taken 4800 times.
52360 if(f>=40 && f<88)
31196 {
31197
2/2
✓ Branch 0 taken 2928 times.
✓ Branch 1 taken 1872 times.
4800 if(get_qr(qr_FADE))
31198 {
31199
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2928 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2928 if (!flash_reduction_enabled() && (f&7) == 0)
31200 {
31201 fade_interpolate(RAMpal,flash_pal,RAMpal,42,0,CSET(6)-1);
31202 refreshpal=true;
31203 }
31204
31205
2/2
✓ Branch 0 taken 2196 times.
✓ Branch 1 taken 732 times.
2928 if((f&3)==2)
31206 {
31207 732 loadpalset(0,0);
31208 732 loadpalset(1,1);
31209 732 loadpalset(5,5);
31210
31211
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 12 times.
732 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
31212 12 else loadlvlpal(0xB); // TODO: Cave/Item Cellar distinction?
31213 732 }
31214 2928 }
31215 else
31216 {
31217
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1872 if(!flash_reduction_enabled() && (f&7) == 0)
31218 {
31219 for(int32_t cs2=2; cs2<5; cs2++)
31220 {
31221 for(int32_t i=1; i<16; i++)
31222 {
31223 RAMpal[CSET(cs2)+i]=flash_pal[CSET(cs2)+i];
31224 }
31225 }
31226
31227 refreshpal=true;
31228 }
31229
31230
2/2
✓ Branch 0 taken 1638 times.
✓ Branch 1 taken 234 times.
1872 if((f&7)==4)
31231 {
31232
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
31233 else loadlvlpal(0xB);
31234
31235 234 loadpalset(5,5);
31236 234 }
31237 }
31238 4800 }
31239
31240
31241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 if(itemsbuf[id2].flags & item_gamedata)
31242 {
31243
2/2
✓ Branch 0 taken 52260 times.
✓ Branch 1 taken 100 times.
52360 if(f==refill_frame)
31244 {
31245 100 refill_what=REFILL_ALL;
31246 100 refill_why=id2;
31247 100 StartRefill(REFILL_ALL);
31248 100 refill();
31249 100 }
31250
31251
2/2
✓ Branch 0 taken 47900 times.
✓ Branch 1 taken 4460 times.
52360 if(f==(refill_frame+1))
31252 {
31253
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 4360 times.
4460 if(refill())
31254 {
31255 4360 --f;
31256 4360 }
31257 4460 }
31258 52360 }
31259
31260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 if(itemsbuf[id2].flags & item_flag1) // Warp out flag
31261 {
31262
4/4
✓ Branch 0 taken 27200 times.
✓ Branch 1 taken 25160 times.
✓ Branch 2 taken 19200 times.
✓ Branch 3 taken 8000 times.
52360 if(f>=208 && f<288)
31263 {
31264 8000 ++x2;
31265
31266
3/3
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 3200 times.
✓ Branch 2 taken 1600 times.
8000 switch(++c)
31267 {
31268 case 5:
31269 1600 c=0;
31270 [[fallthrough]];
31271 case 0:
31272 case 2:
31273 case 3:
31274 4800 ++x2;
31275 4800 break;
31276 }
31277 8000 }
31278
31279 52360 do_dcounters();
31280
31281
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 33160 times.
52360 if(f<288)
31282 {
31283 33160 curtain_x=x2&0xF8;
31284 33160 draw_screen_clip_rect_x1=curtain_x;
31285 33160 draw_screen_clip_rect_x2=255-curtain_x;
31286 33160 draw_screen_clip_rect_y1=0;
31287 33160 draw_screen_clip_rect_y2=223;
31288 //draw_screen(tmpscr);
31289 33160 }
31290 52360 }
31291
31292 52360 draw_screen(tmpscr);
31293 //this causes bugs
31294 //the subscreen appearing over the curtain effect should now be fixed in draw_screen
31295 //so this is not necessary -DD
31296 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,false);
31297
31298 //Run Triforce Script
31299 52360 advanceframe(true);
31300 52360 ++f;
31301
2/2
✓ Branch 0 taken 52260 times.
✓ Branch 1 taken 100 times.
104720 }
31302 while
31303 (
31304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 (f < ( (itemsbuf[id2].misc4 > 0) ? itemsbuf[id2].misc4 : 408))
31305
4/6
✓ Branch 0 taken 7300 times.
✓ Branch 1 taken 45060 times.
✓ Branch 2 taken 7300 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7300 times.
52360 || (!(itemsbuf[id2].flags & item_flag15) /*&& !(itemsbuf[id2].flags & item_flag11)*/ && (midi_pos > 0 && !replay_is_active()))
31306
2/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 7300 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7300 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14600 || (/*!(itemsbuf[id2].flags & item_flag15) &&*/ !(itemsbuf[id2].flags & item_flag11) && (zcmusic!=NULL) && (zcmusic->position<800 && !replay_is_active())
31307 // Music is played at the same speed when fps is uncapped, so in replay mode we need to ignore the music position and instead
31308 // just count frames. 480 is the number of frames it takes for the triforce song in classic_1st.qst to finish playing, but the exact
31309 // value doesn't matter.
31310
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7300 times.
7300 || (replay_is_active() && f < 480) )
31311 ); // 800 may not be just right, but it works
31312
31313 100 action=none; FFCore.setHeroAction(none);
31314 100 holdclk=0;
31315 100 draw_screen_clip_rect_x1=0;
31316 100 draw_screen_clip_rect_x2=255;
31317 100 draw_screen_clip_rect_y1=0;
31318 100 draw_screen_clip_rect_y2=223;
31319 100 show_subscreen_items=true;
31320
31321 //Warp Hero out of item cellars, in 2.10 and earlier quests. -Z ( 16th January, 2019 )
31322 //Added a QR for this, to Other->2, as `Triforce in Cellar Warps Hero Out`. -Z 15th March, 2019
31323
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 1 times.
100 if((itemsbuf[id2].flags & item_flag1) && ( get_qr(qr_SIDEVIEWTRIFORCECELLAR) ? ( currscr < MAPSCRS192b136 ) : (currscr < MAPSCRSNORMAL) ) )
31324 {
31325 99 sdir=dir;
31326 99 dowarp(1,0); //side warp
31327 99 }
31328 else
31329 {
31330
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if ( !(itemsbuf[id2].flags & item_flag11) ) playLevelMusic();
31331 }
31332 100 }
31333
31334 28450 void red_shift()
31335 {
31336 28450 int32_t tnum=176;
31337
31338 // set up the new palette
31339
2/2
✓ Branch 0 taken 910400 times.
✓ Branch 1 taken 28450 times.
938850 for(int32_t i=CSET(2); i < CSET(4); i++)
31340 {
31341 910400 int32_t r = (i-CSET(2)) << 1;
31342 910400 RAMpal[i+tnum].r = _rgb_scale_6[r];
31343 910400 RAMpal[i+tnum].g = _rgb_scale_6[r >> 3];
31344 910400 RAMpal[i+tnum].b = _rgb_scale_6[r >> 4];
31345 910400 }
31346
31347 // color scale the game screen
31348
2/2
✓ Branch 0 taken 4779600 times.
✓ Branch 1 taken 28450 times.
4808050 for(int32_t y=0; y<168; y++)
31349 {
31350
2/2
✓ Branch 0 taken 1223577600 times.
✓ Branch 1 taken 4779600 times.
1228357200 for(int32_t x=0; x<256; x++)
31351 {
31352 1223577600 int c = framebuf->line[y+playing_field_offset][x];
31353 1223577600 int r = RAMpal[c].r / 4;
31354 1223577600 int g = RAMpal[c].g / 4;
31355 1223577600 int b = RAMpal[c].b / 4;
31356
2/2
✓ Branch 0 taken 1150787269 times.
✓ Branch 1 taken 72790331 times.
1223577600 int v = zc_min(int32_t(r*0.4 + g*0.6 + b*0.4)>>1,31);
31357
2/2
✓ Branch 0 taken 1222710767 times.
✓ Branch 1 taken 866833 times.
1223577600 putpixel(framebuf, x, y + playing_field_offset, c ? (v + tnum+CSET(2)) : 0);
31358 1223577600 }
31359 4779600 }
31360
31361 28450 refreshpal = true;
31362 28450 }
31363
31364
31365
31366 void setup_red_screen_old()
31367 {
31368 clear_bitmap(framebuf);
31369 rectfill(scrollbuf, 0, 0, 255, 167, 0);
31370
31371 if(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, tmpscr, 0, playing_field_offset, 2);
31372
31373 if(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, tmpscr, 0, playing_field_offset, 2);
31374
31375 if(lenscheck(tmpscr,0)) putscr(scrollbuf, 0, 0, tmpscr);
31376 putscrdoors(scrollbuf,0,0,tmpscr);
31377 blit(scrollbuf, framebuf, 0, 0, 0, playing_field_offset, 256, 168);
31378 do_layer(framebuf, 0, 1, tmpscr, 0, 0, 2);
31379
31380 if(!(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, tmpscr, 0, 0, 2);
31381
31382 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
31383 {
31384 do_layer(framebuf, -2, 0, tmpscr, 0, 0, 2);
31385 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
31386 {
31387 do_layer(framebuf, -2, 1, tmpscr, 0, 0, 2);
31388 do_layer(framebuf, -2, 2, tmpscr, 0, 0, 2);
31389 }
31390 }
31391
31392 if(!(msg_bg_display_buf->clip))
31393 {
31394 blit_msgstr_bg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
31395 }
31396
31397 if(!(msg_portrait_display_buf->clip))
31398 {
31399 blit_msgstr_prt(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
31400 }
31401
31402 if(!(msg_txt_display_buf->clip))
31403 {
31404 blit_msgstr_fg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
31405 }
31406
31407 if(!(pricesdisplaybuf->clip))
31408 {
31409 masked_blit(pricesdisplaybuf, framebuf,0,0,0,playing_field_offset, 256,168);
31410 }
31411
31412 //red shift
31413 // color scale the game screen
31414 for(int32_t y=0; y<168; y++)
31415 {
31416 for(int32_t x=0; x<256; x++)
31417 {
31418 int32_t c = framebuf->line[y+playing_field_offset][x];
31419 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
31420 framebuf->line[y+playing_field_offset][x] = (c ? (r+CSET(2)) : 0);
31421 }
31422 }
31423
31424 // Hero->draw(framebuf);
31425 blit(framebuf,scrollbuf, 0, playing_field_offset, 256, playing_field_offset, 256, 168);
31426
31427 clear_bitmap(framebuf);
31428
31429 if(!((tmpscr->layermap[2]==0||(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)))
31430 && tmpscr->layermap[3]==0
31431 && tmpscr->layermap[4]==0
31432 && tmpscr->layermap[5]==0
31433 && !overheadcombos(tmpscr)))
31434 {
31435 if(!(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, tmpscr, 0, 0, 2);
31436
31437 do_layer(framebuf, 0, 4, tmpscr, 0, 0, 2);
31438 do_layer(framebuf, -1, 0, tmpscr, 0, 0, 2);
31439 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
31440 {
31441 do_layer(framebuf, -1, 1, tmpscr, 0, 0, 2);
31442 do_layer(framebuf, -1, 2, tmpscr, 0, 0, 2);
31443 }
31444 do_layer(framebuf, 0, 5, tmpscr, 0, 0, 2);
31445 do_layer(framebuf, 0, 6, tmpscr, 0, 0, 2);
31446
31447 //do an AND masked blit for messages on top of layers
31448 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(pricesdisplaybuf->clip) || !(msg_portrait_display_buf->clip))
31449 {
31450 BITMAP* subbmp = create_bitmap_ex(8,256,168);
31451 clear_bitmap(subbmp);
31452 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(msg_portrait_display_buf->clip))
31453 {
31454 masked_blit(framebuf, subbmp, 0, playing_field_offset, 0, 0, 256, 168);
31455 if(!(msg_bg_display_buf->clip)) blit_msgstr_bg(subbmp, 0, 0, 0, 0, 256, 168);
31456 if(!(msg_portrait_display_buf->clip)) blit_msgstr_prt(subbmp, 0, 0, 0, 0, 256, 168);
31457 if(!(msg_txt_display_buf->clip)) blit_msgstr_fg(subbmp, 0, 0, 0, 0, 256, 168);
31458 }
31459 for(int32_t y=0; y<168; y++)
31460 {
31461 for(int32_t x=0; x<256; x++)
31462 {
31463 int32_t c1 = framebuf->line[y+playing_field_offset][x];
31464 int32_t c2 = subbmp->line[y][x];
31465 int32_t c3 = pricesdisplaybuf->clip ? 0 : pricesdisplaybuf->line[y][x];
31466
31467 if(c1 && c3)
31468 {
31469 framebuf->line[y+playing_field_offset][x] = c3;
31470 }
31471 else if(c1 && c2)
31472 {
31473 framebuf->line[y+playing_field_offset][x] = c2;
31474 }
31475 }
31476 }
31477 destroy_bitmap(subbmp);
31478 }
31479
31480 //red shift
31481 // color scale the game screen
31482 for(int32_t y=0; y<168; y++)
31483 {
31484 for(int32_t x=0; x<256; x++)
31485 {
31486 int32_t c = framebuf->line[y+playing_field_offset][x];
31487 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
31488 framebuf->line[y+playing_field_offset][x] = r+CSET(2);
31489 }
31490 }
31491 }
31492
31493 blit(framebuf,scrollbuf, 0, playing_field_offset, 0, playing_field_offset, 256, 168);
31494
31495 // set up the new palette
31496 for(int32_t i=CSET(2); i < CSET(4); i++)
31497 {
31498 int32_t r = (i-CSET(2)) << 1;
31499 RAMpal[i].r = r;
31500 RAMpal[i].g = r >> 3;
31501 RAMpal[i].b = r >> 4;
31502 }
31503
31504 refreshpal = true;
31505 }
31506
31507
31508
31509 75 void slide_in_color(int32_t color)
31510 {
31511
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 75 times.
450 for(int32_t i=1; i<16; i+=3)
31512 {
31513 375 RAMpal[CSET(2)+i+2] = RAMpal[CSET(2)+i+1];
31514 375 RAMpal[CSET(2)+i+1] = RAMpal[CSET(2)+i];
31515 375 RAMpal[CSET(2)+i] = NESpal(color);
31516 375 }
31517
31518 75 refreshpal=true;
31519 75 }
31520
31521
31522 274 void HeroClass::heroDeathAnimation()
31523 {
31524 274 int32_t f=0;
31525 274 int32_t deathclk=0,deathfrm=0;
31526
31527 274 action=none; FFCore.setHeroAction(dying); //mayhaps a new action of 'gameover'? -Z
31528
31529 274 kill_sfx(); //call before the onDeath script.
31530
31531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
274 if(!debug_enabled)
31532 {
31533 274 Paused=false;
31534 274 }
31535
31536 /*
31537 game->set_deaths(zc_min(game->get_deaths()+1,999));
31538 dir=down;
31539 music_stop();
31540
31541 attackclk=hclk=superman=0;
31542 scriptcoldet = true;
31543
31544 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
31545
31546
31547
31548 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
31549 quakeclk=wavy=0;
31550
31551 //in original Z1, Hero marker vanishes at death.
31552 //code in subscr.cpp, put_passive_subscr checks the following value.
31553 //color 255 is a GUI color, so quest makers shouldn't be using this value.
31554 //Also, subscreen is static after death in Z1.
31555 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
31556 QMisc.colors.hero_dot = 255;
31557 //doesn't work
31558 //scrollbuf is tampered with by draw_screen()
31559 //put_passive_subscr(scrollbuf, 256, passive_subscreen_offset, false, false);//save this and reuse it.
31560 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
31561 clear_bitmap(subscrbmp);
31562 put_passive_subscr(subscrbmp, 0, passive_subscreen_offset, false, sspUP);
31563 QMisc.colors.hero_dot = tmp_hero_dot;
31564 */
31565 274 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
31566 274 clear_bitmap(subscrbmp);
31567 //get rid off all sprites but Hero
31568 274 guys.clear();
31569 274 items.clear();
31570 274 Ewpns.clear();
31571 274 Lwpns.clear();
31572 274 chainlinks.clear();
31573 274 decorations.clear();
31574
31575 274 kill_subscr_items();
31576
31577 274 Playing = false;
31578
31579
1/2
✓ Branch 0 taken 274 times.
✗ Branch 1 not taken.
274 game->set_deaths(zc_min(game->get_deaths()+1,USHRT_MAX));
31580 274 dir=down;
31581 274 music_stop();
31582
31583 274 attackclk=hclk=superman=0;
31584 274 scriptcoldet = true;
31585
31586
2/2
✓ Branch 0 taken 8768 times.
✓ Branch 1 taken 274 times.
9042 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
31587
31588
31589
31590 274 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
31591 274 quakeclk=wavy=0;
31592
31593 //in original Z1, Hero marker vanishes at death.
31594 //code in subscr.cpp, put_passive_subscr checks the following value.
31595 //color 255 is a GUI color, so quest makers shouldn't be using this value.
31596 //Also, subscreen is static after death in Z1.
31597 274 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
31598 274 QMisc.colors.hero_dot = 255;
31599 //doesn't work
31600 //scrollbuf is tampered with by draw_screen()
31601 //put_passive_subscr(scrollbuf, 256, passive_subscreen_offset, false, false);//save this and reuse it.
31602
31603 274 put_passive_subscr(subscrbmp, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
31604 //Don't forget passive subscreen scripts!
31605
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 22 times.
274 if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
31606 {
31607 22 script_drawing_commands.Clear(); //We only want draws from this script
31608
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(DMaps[currdmap].passive_sub_script != 0)
31609 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
31610
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22 if (FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && DMaps[currdmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen))
31611 {
31612 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
31613 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
31614 }
31615 22 BITMAP* tmp = framebuf;
31616 22 framebuf = subscrbmp; //Hack; force draws to subscrbmp
31617 22 do_script_draws(framebuf, tmpscr, 0, playing_field_offset); //Draw the script draws
31618 22 framebuf = tmp;
31619 22 script_drawing_commands.Clear(); //Don't let these draws repeat during 'draw_screen()'
31620 22 }
31621 274 QMisc.colors.hero_dot = tmp_hero_dot;
31622 274 bool clearedit = false;
31623 274 do
31624 {
31625
2/2
✓ Branch 0 taken 69204 times.
✓ Branch 1 taken 25359 times.
94563 if(f<254)
31626 {
31627
2/2
✓ Branch 0 taken 60226 times.
✓ Branch 1 taken 8978 times.
69204 if(f<=32)
31628 {
31629 8978 hclk=(32-f);
31630 8978 }
31631
31632
4/4
✓ Branch 0 taken 52338 times.
✓ Branch 1 taken 16866 times.
✓ Branch 2 taken 31711 times.
✓ Branch 3 taken 20627 times.
69204 if(f>=62 && f<138)
31633 {
31634
5/5
✓ Branch 0 taken 16284 times.
✓ Branch 1 taken 1086 times.
✓ Branch 2 taken 1086 times.
✓ Branch 3 taken 1086 times.
✓ Branch 4 taken 1085 times.
20627 switch((f-62)%20)
31635 {
31636 case 0:
31637 1086 dir=right;
31638 1086 break;
31639
31640 case 5:
31641 1086 dir=up;
31642 1086 break;
31643
31644 case 10:
31645 1086 dir=left;
31646 1086 break;
31647
31648 case 15:
31649 1085 dir=down;
31650 1085 break;
31651 }
31652
31653 20627 herostep();
31654 20627 }
31655
31656
4/4
✓ Branch 0 taken 16535 times.
✓ Branch 1 taken 52669 times.
✓ Branch 2 taken 12446 times.
✓ Branch 3 taken 4089 times.
69204 if(f>=194 && f<208)
31657 {
31658
2/2
✓ Branch 0 taken 3818 times.
✓ Branch 1 taken 271 times.
4089 if(f==194)
31659 {
31660 271 action=dying;
31661 271 FFCore.setHeroAction(dying);
31662 271 }
31663
31664 4089 extend = 0;
31665 4089 cs = wpnsbuf[spr_death].csets&15;
31666 4089 tile = wpnsbuf[spr_death].tile;
31667
2/2
✓ Branch 0 taken 3514 times.
✓ Branch 1 taken 575 times.
4089 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
31668 {
31669 575 tile += deathfrm;
31670 575 f = 206;
31671
2/2
✓ Branch 0 taken 495 times.
✓ Branch 1 taken 80 times.
575 if(++deathclk >= wpnsbuf[spr_death].speed)
31672 {
31673 80 deathclk=0;
31674
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 20 times.
80 if(++deathfrm >= wpnsbuf[spr_death].frames)
31675 {
31676 20 f = 208;
31677 20 deathfrm = 0;
31678 20 }
31679 80 }
31680 575 }
31681
2/2
✓ Branch 0 taken 2632 times.
✓ Branch 1 taken 882 times.
3514 else if(BSZ)
31682 {
31683 2632 tile += (f-194)/3;
31684 2632 }
31685
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 252 times.
882 else if(f>=204)
31686 {
31687 252 ++tile;
31688 252 }
31689 4089 }
31690
31691
2/2
✓ Branch 0 taken 68933 times.
✓ Branch 1 taken 271 times.
69204 if(f==208)
31692 {
31693
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 267 times.
271 if ( dontdraw < 2 ) { dontdraw = 1; }
31694 271 }
31695
2/2
✓ Branch 0 taken 65394 times.
✓ Branch 1 taken 3810 times.
69204 if(get_qr(qr_FADE))
31696 {
31697
2/2
✓ Branch 0 taken 43615 times.
✓ Branch 1 taken 21779 times.
65394 if(f < 170)
31698 {
31699
2/2
✓ Branch 0 taken 28193 times.
✓ Branch 1 taken 15422 times.
43615 if(f<60)
31700 {
31701 15422 draw_screen(tmpscr);
31702 //reuse our static subscreen
31703 15422 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
31704 15422 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31705 15422 }
31706
31707
2/2
✓ Branch 0 taken 43358 times.
✓ Branch 1 taken 257 times.
43615 if(f==60)
31708 {
31709 257 red_shift();
31710 257 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
31711 257 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
31712 257 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
31713
31714
2/2
✓ Branch 0 taken 65792 times.
✓ Branch 1 taken 257 times.
66049 for(int32_t q=0; q<PAL_SIZE; q++)
31715 {
31716 65792 trans_table2.data[0][q] = q;
31717 65792 trans_table2.data[q][q] = q;
31718 65792 }
31719 257 }
31720
31721
3/4
✓ Branch 0 taken 28193 times.
✓ Branch 1 taken 15422 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28193 times.
43615 if(f>=60 && f<=169)
31722 {
31723 28193 draw_screen(tmpscr);
31724 //reuse our static subscreen
31725 28193 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31726 28193 red_shift();
31727
31728 28193 }
31729
31730
3/4
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 35679 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7936 times.
43615 if(f>=139 && f<=169)//fade from red to black
31731 {
31732 7936 fade_interpolate(RAMpal,black_palette,RAMpal, (f-138)<<1, 224, 255);
31733 7936 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
31734 7936 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
31735 7936 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
31736
31737
2/2
✓ Branch 0 taken 2031616 times.
✓ Branch 1 taken 7936 times.
2039552 for(int32_t q=0; q<PAL_SIZE; q++)
31738 {
31739 2031616 trans_table2.data[0][q] = q;
31740 2031616 trans_table2.data[q][q] = q;
31741 2031616 }
31742
31743 7936 refreshpal=true;
31744 7936 }
31745 43615 }
31746 else //f>=170
31747 {
31748
2/2
✓ Branch 0 taken 21523 times.
✓ Branch 1 taken 256 times.
21779 if(f==170)//make Hero grayish
31749 {
31750 256 fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
31751
31752
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 256 times.
4352 for(int32_t i=CSET(6); i < CSET(7); i++)
31753 {
31754 4096 int32_t g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
31755 4096 RAMpal[i] = _RGB(g,g,g);
31756 4096 }
31757
31758 256 refreshpal = true;
31759 256 }
31760
31761 //draw only hero. otherwise black layers might cover him.
31762 21779 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
31763 21779 draw(framebuf);
31764 21779 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31765 }
31766 65394 }
31767 else //!qr_FADE
31768 {
31769
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==58)
31770 {
31771
2/2
✓ Branch 0 taken 1440 times.
✓ Branch 1 taken 15 times.
1455 for(int32_t i = 0; i < 96; i++)
31772 1440 tmpscr->cset[i] = 3;
31773
31774
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 15 times.
105 for(int32_t j=0; j<6; j++)
31775
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 2 times.
92 if(tmpscr->layermap[j]>0)
31776
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2 times.
194 for(int32_t i=0; i<96; i++)
31777 194 tmpscr2[j].cset[i] = 3;
31778 15 }
31779
31780
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==59)
31781 {
31782
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 15 times.
1215 for(int32_t i = 96; i < 176; i++)
31783 1200 tmpscr->cset[i] = 3;
31784
31785
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 15 times.
105 for(int32_t j=0; j<6; j++)
31786
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 2 times.
92 if(tmpscr->layermap[j]>0)
31787
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 2 times.
162 for(int32_t i=96; i<176; i++)
31788 162 tmpscr2[j].cset[i] = 3;
31789 15 }
31790
31791
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==60)
31792 {
31793
2/2
✓ Branch 0 taken 2640 times.
✓ Branch 1 taken 15 times.
2655 for(int32_t i=0; i<176; i++)
31794 {
31795 2640 tmpscr->cset[i] = 2;
31796 2640 }
31797
31798
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 15 times.
105 for(int32_t j=0; j<6; j++)
31799
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 2 times.
92 if(tmpscr->layermap[j]>0)
31800
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2 times.
354 for(int32_t i=0; i<176; i++)
31801 354 tmpscr2[j].cset[i] = 2;
31802
31803
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 15 times.
90 for(int32_t i=1; i<16; i+=3)
31804 {
31805 75 RAMpal[CSET(2)+i] = NESpal(0x17);
31806 75 RAMpal[CSET(2)+i+1] = NESpal(0x16);
31807 75 RAMpal[CSET(2)+i+2] = NESpal(0x26);
31808 75 }
31809
31810 15 refreshpal=true;
31811 15 }
31812
31813
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==139)
31814 15 slide_in_color(0x06);
31815
31816
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==149)
31817 15 slide_in_color(0x07);
31818
31819
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==159)
31820 15 slide_in_color(0x0F);
31821
31822
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==169)
31823 {
31824 15 slide_in_color(0x0F);
31825 15 slide_in_color(0x0F);
31826 15 }
31827
31828
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==170)
31829 {
31830
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 15 times.
90 for(int32_t i=1; i<16; i+=3)
31831 {
31832 75 RAMpal[CSET(6)+i] = NESpal(0x10);
31833 75 RAMpal[CSET(6)+i+1] = NESpal(0x30);
31834 75 RAMpal[CSET(6)+i+2] = NESpal(0x00);
31835 75 refreshpal = true;
31836 75 }
31837 15 }
31838
31839
2/2
✓ Branch 0 taken 2535 times.
✓ Branch 1 taken 1275 times.
3810 if(f < 169)
31840 {
31841 2535 draw_screen(tmpscr);
31842 //reuse our static subscreen
31843 2535 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31844 2535 }
31845 else
31846 {
31847 //draw only hero. otherwise black layers might cover him.
31848 1275 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
31849 1275 draw(framebuf);
31850 1275 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31851 }
31852 }
31853 69204 }
31854
31855
2/2
✓ Branch 0 taken 24591 times.
✓ Branch 1 taken 768 times.
25359 else if(f<350)//draw 'GAME OVER' text
31856 {
31857
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24591 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24591 if(get_qr(qr_INSTANT_RESPAWN) && !get_qr(qr_INSTANT_CONTINUE))
31858 {
31859 Quit = qRELOAD;
31860 skipcont = 1;
31861 clear_bitmap(framebuf);
31862 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31863 }
31864
3/4
✓ Branch 0 taken 24591 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24576 times.
✓ Branch 3 taken 15 times.
24591 else if(!get_qr(qr_INSTANT_RESPAWN) && get_qr(qr_INSTANT_CONTINUE))
31865 {
31866 15 Quit = qCONT;
31867 15 skipcont = 1;
31868 15 clear_bitmap(framebuf);
31869 15 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31870 15 }
31871 else
31872 {
31873 24576 clear_info_bmp();
31874 24576 clear_to_color(framebuf,SaveScreenSettings[SAVESC_BACKGROUND]);
31875 24576 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31876 24576 textout_ex(framebuf,get_zc_font(font_zfont),"GAME OVER",96,playing_field_offset+80,SaveScreenSettings[SAVESC_TEXT],-1);
31877 }
31878 24591 }
31879 else
31880 {
31881 768 clear_bitmap(framebuf);
31882 }
31883
31884 //SFX... put them all here
31885
4/4
✓ Branch 0 taken 93766 times.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 272 times.
✓ Branch 3 taken 251 times.
94563 switch(f)
31886 {
31887 case 0:
31888 274 sfx(getHurtSFX(),pan(x.getInt()));
31889 274 break;
31890 //Death sound.
31891 case 60:
31892 272 sfx(WAV_SPIRAL);
31893 272 break;
31894 //Message sound.
31895 case 194:
31896 251 sfx(WAV_MSG);
31897 251 break;
31898 }
31899 //adv:
31900 94563 clear_darkroom_bitmaps();
31901 94563 advanceframe(true);
31902 94563 ++f;
31903
2/2
✓ Branch 0 taken 94289 times.
✓ Branch 1 taken 274 times.
189126 }
31904
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 94307 times.
94563 while(f<353 && !Quit);
31905
31906 274 destroy_bitmap(subscrbmp);
31907 274 action=none; FFCore.setHeroAction(none);
31908
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 270 times.
274 if ( dontdraw < 2 ) { dontdraw=0; }
31909 274 }
31910
31911
31912 17 void HeroClass::ganon_intro()
31913 {
31914 /*
31915 ************************
31916 * GANON INTRO SEQUENCE *
31917 ************************
31918 -25 DOT updates
31919 -24 HERO in
31920 0 TRIFORCE overhead - code begins at this point (f == 0)
31921 47 GANON in
31922 58 LIGHT step
31923 68 LIGHT step
31924 78 LIGHT step
31925 255 TRIFORCE out
31926 256 TRIFORCE in
31927 270 TRIFORCE out
31928 271 GANON out, HERO face up
31929 */
31930 17 loaded_guys=true;
31931 17 loaditem();
31932
31933
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 13 times.
17 if(game->lvlitems[dlevel]&liBOSS)
31934 {
31935 4 return;
31936 }
31937
31938 13 dir=down;
31939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if ( !isSideViewHero() )
31940 {
31941 13 fall = 0; //Fix midair glitch on holding triforce. -Z
31942 13 fakefall = 0;
31943 13 z = 0;
31944 13 fakez = 0;
31945 13 }
31946 13 action=landhold2; FFCore.setHeroAction(landhold2);
31947 13 holditem=getItemID(itemsbuf,itype_triforcepiece, 1);
31948 //not good, as this only returns the highest level that Hero possesses. -DD
31949 //getHighestLevelOfFamily(game, itemsbuf, itype_triforcepiece, false));
31950
31951
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3133 times.
✓ Branch 2 taken 3133 times.
✓ Branch 3 taken 13 times.
3146 for(int32_t f=0; f<271 && !Quit; f++)
31952 {
31953
2/2
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
3133 if(f==47)
31954 {
31955 13 music_stop();
31956 13 stop_sfx(WAV_ROAR);
31957 13 sfx(WAV_GASP);
31958 13 sfx(WAV_GANON);
31959 13 int32_t Id=0;
31960
31961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 for(int32_t i=0; i<eMAXGUYS; i++)
31962 {
31963
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 13 times.
1027 if(guysbuf[i].flags&guy_ganon)
31964 {
31965 13 Id=i;
31966 13 break;
31967 }
31968 1014 }
31969
31970
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 3 times.
13 if(current_item(itype_ring))
31971 {
31972 10 addenemy(160,96,Id,0);
31973 10 }
31974 else
31975 {
31976 3 addenemy(80,32,Id,0);
31977 }
31978 13 }
31979
31980
2/2
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
3133 if(f==48)
31981 {
31982 13 lighting(true,true); // Hmm. -L
31983 13 f += 30;
31984 13 }
31985
31986 //NES Z1, the triforce vanishes for one frame in two cases
31987 //while still showing Hero's two-handed overhead sprite.
31988 //This should be a Quest Rule for NES Accuracy. -Z
31989
4/4
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 3107 times.
3133 if(f==255 || f==270)
31990 {
31991 26 holditem=-1;
31992 26 }
31993
31994
2/2
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
3133 if(f==256)
31995 {
31996 13 holditem=getItemID(itemsbuf,itype_triforcepiece,1);
31997 13 }
31998
31999 3133 draw_screen(tmpscr);
32000 3133 advanceframe(true);
32001
32002
1/2
✓ Branch 0 taken 3133 times.
✗ Branch 1 not taken.
3133 if(rSbtn())
32003 {
32004 conveyclk=3;
32005 int32_t tmp_subscr_clk = frame;
32006 dosubscr();
32007 newscr_clk += frame - tmp_subscr_clk;
32008 }
32009
32010 3133 }
32011
32012 13 action=none; FFCore.setHeroAction(none);
32013 13 dir=up;
32014
32015
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 11 times.
13 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && (tunes[MAXMIDIS-1].data))
32016 2 jukebox(MAXMIDIS-1);
32017 else
32018 11 playLevelMusic();
32019
32020 13 currcset=DMaps[currdmap].color;
32021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (get_qr(qr_GANONINTRO) )
32022 {
32023 13 dointro();
32024 //Yes, I checked. This is literally in 2.10 (minus this if statement of course).
32025 //I have no clue why it's here; Literally the only difference between dointro in 2.10 and dointro in this version is an 'else' that sets introclk and intropos to 74.
32026 //I have no idea what was going through the original devs heads and I'm extremely worried I'm missing something, cause at first glance this looks like
32027 //a hack solution to an underlying bug, but no! There's just a fucking dointro() call in older versions and I don't know *why*. -Deedee
32028 13 }
32029 //dointro(); //This is likely what causes Ganon Rooms to repeat the DMap intro.
32030 //I suppose it is to allow the user to make Gaanon rooms have their own dialogue, if they are
32031 //on a different DMap.
32032 //~ Otherwise, why is it here?! -Z
32033
32034
32035 //if ( !(DMaps[currdmap].flags&dmfALWAYSMSG) ) { dointro(); } //This is likely what causes Ganon Rooms to repeat the DMap intro.
32036 //If we try it this way: The dmap flag /always display intro string/ is probably why James had this issue.
32037
32038 //The only fix that I can think of, off the top of me head, is either a QR or a Screen Flag to disable the intro text.
32039 //Users who use that dmap rule should put ganons room on its own DMap! -Z
32040 13 cont_sfx(WAV_ROAR);
32041 17 }
32042
32043 10 void HeroClass::win_game()
32044 {
32045
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 replay_step_comment("win_game");
32046 10 Playing=Paused=false;
32047 10 action=won; FFCore.setHeroAction(won);
32048 10 Quit=qWON;
32049 10 hclk=0;
32050 10 x = 136;
32051
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 y = (isdungeon() && currscr<128) ? 75 : 73;
32052 10 z = fakez = fall = fakefall = spins = 0;
32053 10 dir=left;
32054 10 }
32055
32056 39442 void HeroClass::reset_swordcharge()
32057 {
32058 39442 charging=spins=tapping=0;
32059 39442 }
32060
32061 137953 void HeroClass::reset_hookshot()
32062 {
32063
10/12
✓ Branch 0 taken 89027 times.
✓ Branch 1 taken 48926 times.
✓ Branch 2 taken 89013 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 88932 times.
✓ Branch 5 taken 81 times.
✓ Branch 6 taken 88925 times.
✓ Branch 7 taken 7 times.
✓ Branch 8 taken 88925 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 88925 times.
137953 if(action!=walking && action!=rafting && action!=landhold1 && action!=landhold2 && action!=sidewaterhold1 && action!=sidewaterhold2)
32064 {
32065 88925 action=none; FFCore.setHeroAction(none);
32066 88925 }
32067
32068 137953 hookshot_frozen=false;
32069 137953 hookshot_used=false;
32070 137953 pull_hero=false;
32071 137953 hs_fix=false;
32072 137953 switchhookclk = switchhookmaxtime = switchhookstyle = switchhookarg = 0;
32073 137953 switch_hooked = false;
32074
2/2
✓ Branch 0 taken 137948 times.
✓ Branch 1 taken 5 times.
137953 if(switching_object)
32075 5 switching_object->switch_hooked = false;
32076 137953 switching_object = NULL;
32077 137953 hooked_combopos = -1;
32078 137953 switchhook_cost_item = -1;
32079 137953 hooked_layerbits = 0;
32080
2/2
✓ Branch 0 taken 965671 times.
✓ Branch 1 taken 137953 times.
1103624 for(auto q = 0; q < 7; ++q)
32081 965671 hooked_undercombos[q] = -1;
32082 137953 Lwpns.del(Lwpns.idFirst(wHSHandle));
32083 137953 Lwpns.del(Lwpns.idFirst(wHookshot));
32084 137953 chainlinks.clear();
32085
2/2
✓ Branch 0 taken 33496 times.
✓ Branch 1 taken 104457 times.
137953 int32_t index=directWpn>-1 ? directWpn : current_item_id(hs_switcher ? itype_switchhook : itype_hookshot);
32086 137953 hs_switcher = false;
32087
32088
2/2
✓ Branch 0 taken 94440 times.
✓ Branch 1 taken 43513 times.
137953 if(index>=0)
32089 {
32090 43513 stop_sfx(itemsbuf[index].usesound);
32091 43513 }
32092
32093 137953 hs_xdist=0;
32094 137953 hs_ydist=0;
32095 137953 }
32096
32097
32098 17004899 bool HeroClass::can_deploy_ladder()
32099 {
32100
2/2
✓ Branch 0 taken 7099135 times.
✓ Branch 1 taken 9905764 times.
29992922 bool ladderallowed = ((!get_qr(qr_LADDERANYWHERE) && (tmpscr->flags&fLADDER)) || isdungeon()
32101
4/4
✓ Branch 0 taken 3924191 times.
✓ Branch 1 taken 12988023 times.
✓ Branch 2 taken 4778180 times.
✓ Branch 3 taken 8209843 times.
9905764 || (get_qr(qr_LADDERANYWHERE) && !(tmpscr->flags&fLADDER)));
32102
9/10
✓ Branch 0 taken 6585084 times.
✓ Branch 1 taken 17426265 times.
✓ Branch 2 taken 2925049 times.
✓ Branch 3 taken 3660035 times.
✓ Branch 4 taken 2924797 times.
✓ Branch 5 taken 252 times.
✓ Branch 6 taken 2924092 times.
✓ Branch 7 taken 705 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2924092 times.
26935441 return (current_item_id(itype_ladder)>-1 && ladderallowed && !ilswim && z==0 && fakez==0 &&
32103
2/2
✓ Branch 0 taken 2903281 times.
✓ Branch 1 taken 20811 times.
2924092 (!isSideViewHero() || on_sideview_solid_oldpos(this)));
32104 }
32105
32106 9609084 void HeroClass::reset_ladder()
32107 {
32108 9609084 ladderx=laddery=0;
32109 9609084 }
32110
32111 bool is_conveyor(int32_t type);
32112 int32_t get_conveyor(int32_t x, int32_t y);
32113
32114 14168556 void HeroClass::check_conveyor()
32115 {
32116 14168556 ++newconveyorclk;
32117
32118
2/2
✓ Branch 0 taken 14165339 times.
✓ Branch 1 taken 3217 times.
14168556 if (is_conveyor_stunned)
32119 3217 --is_conveyor_stunned;
32120
32121
16/18
✓ Branch 0 taken 14164661 times.
✓ Branch 1 taken 3895 times.
✓ Branch 2 taken 14164661 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14158677 times.
✓ Branch 5 taken 5984 times.
✓ Branch 6 taken 14158677 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14158421 times.
✓ Branch 9 taken 256 times.
✓ Branch 10 taken 14151126 times.
✓ Branch 11 taken 7295 times.
✓ Branch 12 taken 14133943 times.
✓ Branch 13 taken 17183 times.
✓ Branch 14 taken 14115307 times.
✓ Branch 15 taken 18636 times.
✓ Branch 16 taken 14115587 times.
✓ Branch 17 taken 18356 times.
14168556 if(action==casting||action==sideswimcasting||action==drowning || action==sidedrowning||action==lavadrowning||inlikelike||pull_hero||((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)))
32122 {
32123 52969 is_conveyor_stunned = 0;
32124 52969 return;
32125 }
32126
32127 14115587 WalkflagInfo info;
32128 int32_t xoff,yoff;
32129 14115587 zfix deltax(0), deltay(0);
32130 14115587 int32_t cmbid = get_conveyor(x+7,y+(bigHitbox?8:12));
32131
2/2
✓ Branch 0 taken 19053 times.
✓ Branch 1 taken 14096534 times.
14115587 if(cmbid < 0)
32132 {
32133
2/2
✓ Branch 0 taken 9418946 times.
✓ Branch 1 taken 4677588 times.
14096534 if (conveyclk <= 0)
32134 {
32135 4677588 is_on_conveyor = false;
32136 4677588 conv_forcedir = -1;
32137 4677588 }
32138 14096534 return;
32139 }
32140 19053 newcombo const* cmb = &combobuf[cmbid];
32141 19053 auto pos = COMBOPOS(x+7,y+(bigHitbox?8:12));
32142 19053 bool custom_spd = (cmb->usrflags&cflag2);
32143
3/4
✓ Branch 0 taken 15782 times.
✓ Branch 1 taken 3271 times.
✓ Branch 2 taken 15782 times.
✗ Branch 3 not taken.
19053 if(custom_spd || conveyclk<=0) //!DIMITODO: let player be on multiple conveyors at once
32144 {
32145 19053 int32_t ctype=cmb->type;
32146
3/4
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 15782 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3271 times.
19053 auto rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
32147
3/4
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 15782 times.
✓ Branch 2 taken 3271 times.
✗ Branch 3 not taken.
19053 if(custom_spd && (newconveyorclk % rate)) return;
32148
3/4
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 15782 times.
✓ Branch 2 taken 3271 times.
✗ Branch 3 not taken.
19053 if((cmb->usrflags&cflag5) && HasHeavyBoots())
32149 return;
32150 19053 is_on_conveyor=false;
32151 19053 conv_forcedir=-1;
32152 19053 is_conveyor_stunned=0;
32153
32154 19053 deltax=combo_class_buf[ctype].conveyor_x_speed;
32155 19053 deltay=combo_class_buf[ctype].conveyor_y_speed;
32156
32157
3/4
✓ Branch 0 taken 19053 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15782 times.
✓ Branch 3 taken 3271 times.
19053 if (is_conveyor(ctype) && custom_spd)
32158 {
32159 3271 deltax = zslongToFix(cmb->attributes[0]);
32160 3271 deltay = zslongToFix(cmb->attributes[1]);
32161 3271 }
32162
32163
3/8
✓ Branch 0 taken 8708 times.
✓ Branch 1 taken 10345 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8708 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
19053 if((deltax==0&&deltay==0)&&(isSideViewHero() && on_sideview_solid_oldpos(this)))
32164 {
32165 cmbid = MAPCOMBO(x+8,y+16);
32166 cmb = &combobuf[cmbid];
32167 custom_spd = cmb->usrflags&cflag2;
32168 ctype=(cmb->type);
32169 rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
32170 deltax=combo_class_buf[ctype].conveyor_x_speed;
32171 deltay=combo_class_buf[ctype].conveyor_y_speed;
32172 if ((deltax != 0 || deltay != 0) && custom_spd)
32173 {
32174 deltax = zslongToFix(cmb->attributes[0]);
32175 deltay = zslongToFix(cmb->attributes[1]);
32176 }
32177 }
32178
32179
3/4
✓ Branch 0 taken 8708 times.
✓ Branch 1 taken 10345 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8708 times.
19053 if(deltax!=0||deltay!=0)
32180 {
32181 19053 is_on_conveyor=true;
32182 19053 }
32183 else return;
32184
32185
1/2
✓ Branch 0 taken 19053 times.
✗ Branch 1 not taken.
19053 bool forcewalk = (cmb->usrflags&cflag6) && get_qr(qr_NEW_HERO_MOVEMENT2);
32186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19053 times.
19053 if(forcewalk)
32187 {
32188 is_conveyor_stunned = rate;
32189 if((cmb->usrflags&cflag3) && !spins)
32190 {
32191 if(abs(deltax) > abs(deltay))
32192 conv_forcedir = dir = (deltax > 0) ? right : left;
32193 else conv_forcedir = dir = (deltay > 0) ? down : up;
32194 }
32195 convey_forcex = deltax;
32196 convey_forcey = deltay;
32197 }
32198 else
32199 {
32200 19053 bool movedx = false, movedy = false;
32201
2/2
✓ Branch 0 taken 15782 times.
✓ Branch 1 taken 3271 times.
19053 if(cmb->usrflags&cflag4) //Smart corners
32202 {
32203
2/2
✓ Branch 0 taken 1095 times.
✓ Branch 1 taken 2176 times.
3271 if(deltay<0)
32204 {
32205 1095 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
32206 1095 execute(info);
32207
32208
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 1044 times.
1095 if(!info.isUnwalkable())
32209 {
32210 1044 movedy = true;
32211 1044 zfix step(0);
32212
32213
5/12
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 900 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 144 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1044 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
32214 {
32215 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
32216 {
32217 yoff=int32_t(y-step)&7;
32218
32219 if(!yoff) break;
32220
32221 step++;
32222 }
32223 }
32224 else
32225 {
32226 1044 step=abs(deltay);
32227 }
32228
32229 1044 y=y-step;
32230 1044 hs_starty-=step.getInt();
32231
32232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1044 times.
1044 for(int32_t j=0; j<chainlinks.Count(); j++)
32233 {
32234 chainlinks.spr(j)->y-=step;
32235 }
32236
32237
1/2
✓ Branch 0 taken 1044 times.
✗ Branch 1 not taken.
1044 if(Lwpns.idFirst(wHookshot)>-1)
32238 {
32239 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
32240 }
32241
32242
1/2
✓ Branch 0 taken 1044 times.
✗ Branch 1 not taken.
1044 if(Lwpns.idFirst(wHSHandle)>-1)
32243 {
32244 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
32245 }
32246 1044 }
32247 1095 }
32248
2/2
✓ Branch 0 taken 1769 times.
✓ Branch 1 taken 407 times.
2176 else if(deltay>0)
32249 {
32250 407 info = walkflag(x,y+15+2,2,down);
32251 407 execute(info);
32252
32253
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 402 times.
407 if(!info.isUnwalkable())
32254 {
32255 402 movedy = true;
32256 402 zfix step(0);
32257
32258
7/12
✓ Branch 0 taken 311 times.
✓ Branch 1 taken 91 times.
✓ Branch 2 taken 91 times.
✓ Branch 3 taken 311 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 82 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
402 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
32259 {
32260 while(step<abs(deltay))
32261 {
32262 yoff=int32_t(y+step)&7;
32263
32264 if(!yoff) break;
32265
32266 step++;
32267 }
32268 }
32269 else
32270 {
32271 402 step=abs(deltay);
32272 }
32273
32274 402 y=y+step;
32275 402 hs_starty+=step.getInt();
32276
32277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402 times.
402 for(int32_t j=0; j<chainlinks.Count(); j++)
32278 {
32279 chainlinks.spr(j)->y+=step;
32280 }
32281
32282
1/2
✓ Branch 0 taken 402 times.
✗ Branch 1 not taken.
402 if(Lwpns.idFirst(wHookshot)>-1)
32283 {
32284 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
32285 }
32286
32287
1/2
✓ Branch 0 taken 402 times.
✗ Branch 1 not taken.
402 if(Lwpns.idFirst(wHSHandle)>-1)
32288 {
32289 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
32290 }
32291 402 }
32292 407 }
32293
32294
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 2775 times.
3271 if(deltax<0)
32295 {
32296 496 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
32297 496 execute(info);
32298
32299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496 times.
496 if(!info.isUnwalkable())
32300 {
32301 496 movedx = true;
32302 496 zfix step(0);
32303
32304
7/12
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 486 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
496 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
32305 {
32306 while(step<abs(deltax))
32307 {
32308 xoff=int32_t(x-step)&7;
32309
32310 if(!xoff) break;
32311
32312 step++;
32313 }
32314 }
32315 else
32316 {
32317 496 step=abs(deltax);
32318 }
32319
32320 496 x=x-step;
32321 496 hs_startx-=step.getInt();
32322
32323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496 times.
496 for(int32_t j=0; j<chainlinks.Count(); j++)
32324 {
32325 chainlinks.spr(j)->x-=step;
32326 }
32327
32328
1/2
✓ Branch 0 taken 496 times.
✗ Branch 1 not taken.
496 if(Lwpns.idFirst(wHookshot)>-1)
32329 {
32330 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
32331 }
32332
32333
1/2
✓ Branch 0 taken 496 times.
✗ Branch 1 not taken.
496 if(Lwpns.idFirst(wHSHandle)>-1)
32334 {
32335 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
32336 }
32337 496 }
32338 496 }
32339
2/2
✓ Branch 0 taken 1502 times.
✓ Branch 1 taken 1273 times.
2775 else if(deltax>0)
32340 {
32341 1273 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
32342 1273 execute(info);
32343
32344
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1259 times.
1273 if(!info.isUnwalkable())
32345 {
32346 1259 movedx = true;
32347 1259 zfix step(0);
32348
32349
7/12
✓ Branch 0 taken 1093 times.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 181 times.
✓ Branch 3 taken 1078 times.
✓ Branch 4 taken 134 times.
✓ Branch 5 taken 47 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 134 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1259 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
32350 {
32351 while(step<abs(deltax))
32352 {
32353 xoff=int32_t(x+step)&7;
32354
32355 if(!xoff) break;
32356
32357 step++;
32358 }
32359 }
32360 else
32361 {
32362 1259 step=abs(deltax);
32363 }
32364
32365 1259 x=x+step;
32366 1259 hs_startx+=step.getInt();
32367
32368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1259 times.
1259 for(int32_t j=0; j<chainlinks.Count(); j++)
32369 {
32370 chainlinks.spr(j)->x+=step;
32371 }
32372
32373
1/2
✓ Branch 0 taken 1259 times.
✗ Branch 1 not taken.
1259 if(Lwpns.idFirst(wHookshot)>-1)
32374 {
32375 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
32376 }
32377
32378
1/2
✓ Branch 0 taken 1259 times.
✗ Branch 1 not taken.
1259 if(Lwpns.idFirst(wHSHandle)>-1)
32379 {
32380 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
32381 }
32382 1259 }
32383 1273 }
32384
5/6
✓ Branch 0 taken 1769 times.
✓ Branch 1 taken 1502 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 1755 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
3271 if(deltax && !movedx && !deltay)
32385 {
32386 14 zfix oy = y;
32387 14 y = COMBOY(pos);
32388 14 bool validpush = scr_canmove(deltax, 0, false, false);
32389
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
28 zfix ny = handle_movestate_zfix([&]()
32390 {
32391 14 movexy(deltax,0,false,false,true,true);
32392 14 return y;
32393 });
32394 14 y = oy;
32395
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 if (validpush || ny != COMBOY(pos))
32396 {
32397
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (y <= ny-1)
32398 {
32399 14 setYfix(y+1);
32400 14 }
32401 else if (y >= ny+1)
32402 {
32403 setYfix(y-1);
32404 }
32405 else
32406 {
32407 setYfix(ny);
32408 }
32409 14 }
32410 14 }
32411
5/6
✓ Branch 0 taken 1502 times.
✓ Branch 1 taken 1769 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 1446 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
3271 if(deltay && !movedy && !deltax)
32412 {
32413 56 zfix ox = x;
32414 56 x = COMBOX(pos);
32415 56 bool validpush = scr_canmove(0, deltay, false, false);
32416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
112 zfix nx = handle_movestate_zfix([&]()
32417 {
32418 56 movexy(0,deltay,false,false,true,true);
32419 56 return x;
32420 });
32421 56 x = ox;
32422
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
56 if (validpush || nx != COMBOX(pos))
32423 {
32424
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 3 times.
56 if (x <= nx-1)
32425 {
32426 53 setXfix(x+1);
32427 53 }
32428
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if (x >= nx+1)
32429 {
32430 setXfix(x-1);
32431 }
32432 else
32433 {
32434 3 setXfix(nx);
32435 }
32436 56 }
32437 56 }
32438 3271 }
32439
2/2
✓ Branch 0 taken 1446 times.
✓ Branch 1 taken 17607 times.
19053 if(!movedy)
32440 {
32441
2/2
✓ Branch 0 taken 2764 times.
✓ Branch 1 taken 14843 times.
17607 if(deltay<0)
32442 {
32443 2764 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
32444 2764 execute(info);
32445
32446
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 2517 times.
2764 if(!info.isUnwalkable())
32447 {
32448 2517 movedy = true;
32449 2517 zfix step(0);
32450
32451
10/12
✓ Branch 0 taken 1942 times.
✓ Branch 1 taken 575 times.
✓ Branch 2 taken 703 times.
✓ Branch 3 taken 1814 times.
✓ Branch 4 taken 218 times.
✓ Branch 5 taken 485 times.
✓ Branch 6 taken 195 times.
✓ Branch 7 taken 23 times.
✓ Branch 8 taken 195 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 195 times.
2517 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
32452 {
32453
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 373 times.
530 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
32454 {
32455 373 yoff=int32_t(y-step)&7;
32456
32457
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 38 times.
373 if(!yoff) break;
32458
32459 335 step++;
32460 }
32461 195 }
32462 else
32463 {
32464 2322 step=abs(deltay);
32465 }
32466
32467 2517 y=y-step;
32468 2517 hs_starty-=step.getInt();
32469
32470
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 2517 times.
2536 for(int32_t j=0; j<chainlinks.Count(); j++)
32471 {
32472 19 chainlinks.spr(j)->y-=step;
32473 19 }
32474
32475
2/2
✓ Branch 0 taken 2498 times.
✓ Branch 1 taken 19 times.
2517 if(Lwpns.idFirst(wHookshot)>-1)
32476 {
32477 19 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
32478 19 }
32479
32480
2/2
✓ Branch 0 taken 2498 times.
✓ Branch 1 taken 19 times.
2517 if(Lwpns.idFirst(wHSHandle)>-1)
32481 {
32482 19 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
32483 19 }
32484 2517 }
32485 247 else checkdamagecombos(x,y+8-(bigHitbox ? 8 : 0)-2);
32486 2764 }
32487
2/2
✓ Branch 0 taken 10345 times.
✓ Branch 1 taken 4498 times.
14843 else if(deltay>0)
32488 {
32489 4498 info = walkflag(x,y+15+2,2,down);
32490 4498 execute(info);
32491
32492
2/2
✓ Branch 0 taken 897 times.
✓ Branch 1 taken 3601 times.
4498 if(!info.isUnwalkable())
32493 {
32494 3601 movedy = true;
32495 3601 zfix step(0);
32496
32497
10/12
✓ Branch 0 taken 2879 times.
✓ Branch 1 taken 722 times.
✓ Branch 2 taken 956 times.
✓ Branch 3 taken 2645 times.
✓ Branch 4 taken 444 times.
✓ Branch 5 taken 512 times.
✓ Branch 6 taken 388 times.
✓ Branch 7 taken 56 times.
✓ Branch 8 taken 388 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 388 times.
3601 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
32498 {
32499
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 646 times.
881 while(step<abs(deltay))
32500 {
32501 646 yoff=int32_t(y+step)&7;
32502
32503
2/2
✓ Branch 0 taken 493 times.
✓ Branch 1 taken 153 times.
646 if(!yoff) break;
32504
32505 493 step++;
32506 }
32507 388 }
32508 else
32509 {
32510 3213 step=abs(deltay);
32511 }
32512
32513 3601 y=y+step;
32514 3601 hs_starty+=step.getInt();
32515
32516
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3601 times.
3614 for(int32_t j=0; j<chainlinks.Count(); j++)
32517 {
32518 13 chainlinks.spr(j)->y+=step;
32519 13 }
32520
32521
2/2
✓ Branch 0 taken 3562 times.
✓ Branch 1 taken 39 times.
3601 if(Lwpns.idFirst(wHookshot)>-1)
32522 {
32523 39 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
32524 39 }
32525
32526
2/2
✓ Branch 0 taken 3562 times.
✓ Branch 1 taken 39 times.
3601 if(Lwpns.idFirst(wHSHandle)>-1)
32527 {
32528 39 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
32529 39 }
32530 3601 }
32531 897 else checkdamagecombos(x,y+15);
32532 4498 }
32533 17607 }
32534
2/2
✓ Branch 0 taken 1755 times.
✓ Branch 1 taken 17298 times.
19053 if(!movedx)
32535 {
32536
2/2
✓ Branch 0 taken 5381 times.
✓ Branch 1 taken 11917 times.
17298 if(deltax<0)
32537 {
32538 5381 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
32539 5381 execute(info);
32540
32541
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 5104 times.
5381 if(!info.isUnwalkable())
32542 {
32543 5104 movedx = true;
32544 5104 zfix step(0);
32545
32546
10/12
✓ Branch 0 taken 4579 times.
✓ Branch 1 taken 525 times.
✓ Branch 2 taken 689 times.
✓ Branch 3 taken 4415 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 372 times.
✓ Branch 6 taken 244 times.
✓ Branch 7 taken 73 times.
✓ Branch 8 taken 244 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 244 times.
5104 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
32547 {
32548
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 456 times.
635 while(step<abs(deltax))
32549 {
32550 456 xoff=int32_t(x-step)&7;
32551
32552
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 65 times.
456 if(!xoff) break;
32553
32554 391 step++;
32555 }
32556 244 }
32557 else
32558 {
32559 4860 step=abs(deltax);
32560 }
32561
32562 5104 x=x-step;
32563 5104 hs_startx-=step.getInt();
32564
32565
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 5104 times.
5146 for(int32_t j=0; j<chainlinks.Count(); j++)
32566 {
32567 42 chainlinks.spr(j)->x-=step;
32568 42 }
32569
32570
2/2
✓ Branch 0 taken 5053 times.
✓ Branch 1 taken 51 times.
5104 if(Lwpns.idFirst(wHookshot)>-1)
32571 {
32572 51 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
32573 51 }
32574
32575
2/2
✓ Branch 0 taken 5053 times.
✓ Branch 1 taken 51 times.
5104 if(Lwpns.idFirst(wHSHandle)>-1)
32576 {
32577 51 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
32578 51 }
32579 5104 }
32580 277 else checkdamagecombos(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0));
32581 5381 }
32582
2/2
✓ Branch 0 taken 8708 times.
✓ Branch 1 taken 3209 times.
11917 else if(deltax>0)
32583 {
32584 3209 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
32585 3209 execute(info);
32586
32587
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 3127 times.
3209 if(!info.isUnwalkable())
32588 {
32589 3127 movedx = true;
32590 3127 zfix step(0);
32591
32592
10/12
✓ Branch 0 taken 2627 times.
✓ Branch 1 taken 500 times.
✓ Branch 2 taken 510 times.
✓ Branch 3 taken 2617 times.
✓ Branch 4 taken 309 times.
✓ Branch 5 taken 201 times.
✓ Branch 6 taken 203 times.
✓ Branch 7 taken 106 times.
✓ Branch 8 taken 203 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 203 times.
3127 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
32593 {
32594
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 341 times.
460 while(step<abs(deltax))
32595 {
32596 341 xoff=int32_t(x+step)&7;
32597
32598
2/2
✓ Branch 0 taken 257 times.
✓ Branch 1 taken 84 times.
341 if(!xoff) break;
32599
32600 257 step++;
32601 }
32602 203 }
32603 else
32604 {
32605 2924 step=abs(deltax);
32606 }
32607
32608 3127 x=x+step;
32609 3127 hs_startx+=step.getInt();
32610
32611
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 3127 times.
3148 for(int32_t j=0; j<chainlinks.Count(); j++)
32612 {
32613 21 chainlinks.spr(j)->x+=step;
32614 21 }
32615
32616
2/2
✓ Branch 0 taken 3104 times.
✓ Branch 1 taken 23 times.
3127 if(Lwpns.idFirst(wHookshot)>-1)
32617 {
32618 23 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
32619 23 }
32620
32621
2/2
✓ Branch 0 taken 3104 times.
✓ Branch 1 taken 23 times.
3127 if(Lwpns.idFirst(wHSHandle)>-1)
32622 {
32623 23 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
32624 23 }
32625 3127 }
32626 82 else checkdamagecombos(x+15+2,y+8-(bigHitbox ? 8 : 0));
32627 3209 }
32628 17298 }
32629
4/4
✓ Branch 0 taken 9067 times.
✓ Branch 1 taken 9986 times.
✓ Branch 2 taken 7564 times.
✓ Branch 3 taken 1503 times.
19053 if(movedx || movedy)
32630 {
32631
2/2
✓ Branch 0 taken 14333 times.
✓ Branch 1 taken 3217 times.
17550 if(cmb->usrflags&cflag1)
32632 3217 is_conveyor_stunned = rate;
32633
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17550 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17550 if((cmb->usrflags&cflag3) && !spins)
32634 {
32635 if(abs(deltax) > abs(deltay))
32636 conv_forcedir = dir = (deltax > 0) ? right : left;
32637 else conv_forcedir = dir = (deltay > 0) ? down : up;
32638 }
32639 17550 }
32640 }
32641 19053 }
32642 14168556 }
32643
32644 void HeroClass::setDivineProtectionShieldClk(int32_t newclk)
32645 {
32646 DivineProtectionShieldClk=newclk;
32647
32648 if(decorations.idCount(dDIVINEPROTECTIONSHIELD)==0)
32649 {
32650 decoration *dec;
32651 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
32652 decorations.spr(decorations.Count()-1)->misc=0;
32653 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
32654 dec=(decoration *)decorations.spr(decorations.Count()-1);
32655 decorations.spr(decorations.Count()-1)->misc=1;
32656 }
32657 }
32658
32659 35482 int32_t HeroClass::getDivineProtectionShieldClk()
32660 {
32661 35482 return DivineProtectionShieldClk;
32662 }
32663
32664 21 int32_t HeroClass::getHoverClk()
32665 {
32666 21 return hoverclk;
32667 }
32668
32669 25694175 int32_t HeroClass::getHoldClk()
32670 {
32671 25694175 return holdclk;
32672 }
32673
32674 8277003 int32_t HeroClass::getLastLensID(){
32675 8277003 return last_lens_id;
32676 }
32677
32678 209 void HeroClass::setLastLensID(int32_t p_item){
32679 209 last_lens_id = p_item;
32680 209 }
32681
32682 118587052 bool HeroClass::getOnSideviewLadder()
32683 {
32684 118587052 return on_sideview_ladder;
32685 }
32686
32687 394 void HeroClass::setOnSideviewLadder(bool val)
32688 {
32689
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(val)
32690 {
32691 fall = fakefall = hoverclk = jumping = 0;
32692 hoverflags = 0;
32693 inair = false;
32694 }
32695 394 on_sideview_ladder = val;
32696 394 }
32697
32698 4641219 bool HeroClass::canSideviewLadder(bool down)
32699 {
32700
2/2
✓ Branch 0 taken 4607310 times.
✓ Branch 1 taken 33909 times.
4641219 if(!isSideViewHero()) return false;
32701
2/2
✓ Branch 0 taken 20703 times.
✓ Branch 1 taken 13206 times.
33909 if(jumping < 0) return false;
32702
2/2
✓ Branch 0 taken 12184 times.
✓ Branch 1 taken 8519 times.
20703 if (down)
32703 {
32704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8519 times.
8519 if (check_new_slope(x, y + 0.0001_zf, 16, 16, old_x, old_y, true))
32705 {
32706 return false;
32707 }
32708 8519 }
32709
3/4
✓ Branch 0 taken 8519 times.
✓ Branch 1 taken 12184 times.
✓ Branch 2 taken 8519 times.
✗ Branch 3 not taken.
20703 if(down && get_qr(qr_DOWN_DOESNT_GRAB_LADDERS))
32710 {
32711 bool onSolid = on_sideview_solid_oldpos(this,true);
32712 return ((isSVLadder(x+4,y+16) && (!isSVLadder(x+4,y)||onSolid)) || (isSVLadder(x+12,y+16) && (!isSVLadder(x+12,y)||onSolid)));
32713 }
32714 //Are you presently able to climb a sideview ladder?
32715 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
32716 //y+0 checks your top-half for large hitbox; y+8 for small
32717 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
32718 //y+16 check is for going down onto a ladder you are standing on.
32719
1/2
✓ Branch 0 taken 20703 times.
✗ Branch 1 not taken.
41406 return (isSVLadder(x+4,y+(bigHitbox?0:8)) || isSVLadder(x+12,y+(bigHitbox?0:8)))
32720
2/4
✓ Branch 0 taken 20703 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20703 times.
✗ Branch 3 not taken.
20703 || isSVLadder(x+4,y+15) || isSVLadder(x+12,y+15)
32721
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 20703 times.
✓ Branch 2 taken 12184 times.
✓ Branch 3 taken 8519 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8519 times.
29222 || (down && (isSVLadder(x+4,y+16) || isSVLadder(x+12,y+16)));
32722 4641219 }
32723
32724 bool HeroClass::canSideviewLadderRemote(int32_t wx, int32_t wy, bool down)
32725 {
32726 if(!isSideViewHero()) return false;
32727 if(jumping < 0) return false;
32728 if(down && get_qr(qr_DOWN_DOESNT_GRAB_LADDERS))
32729 {
32730 bool onSolid = on_sideview_solid_oldpos(this,true);
32731 return ((isSVLadder(wx+4,wy+16) && (!isSVLadder(wx+4,wy)||onSolid)) || (isSVLadder(wx+12,wy+16) && (!isSVLadder(wx+12,wy)||onSolid)));
32732 }
32733 //Are you presently able to climb a sideview ladder?
32734 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
32735 //y+0 checks your top-half for large hitbox; y+8 for small
32736 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
32737 //y+16 check is for going down onto a ladder you are standing on.
32738 return (isSVLadder(wx+4,wy+(bigHitbox?0:8)) || isSVLadder(wx+12,wy+(bigHitbox?0:8)))
32739 || isSVLadder(wx+4,wy+15) || isSVLadder(wx+12,wy+15)
32740 || (down && (isSVLadder(wx+4,wy+16) || isSVLadder(wx+12,wy+16)));
32741 }
32742
32743 9888056 void HeroClass::execute(HeroClass::WalkflagInfo info)
32744 {
32745 9888056 int32_t flags = info.getFlags();
32746
32747
2/2
✓ Branch 0 taken 1770 times.
✓ Branch 1 taken 9886286 times.
9888056 if(flags & WalkflagInfo::CLEARILSWIM)
32748 1770 ilswim =false;
32749
2/2
✓ Branch 0 taken 9882946 times.
✓ Branch 1 taken 3340 times.
9886286 else if(flags & WalkflagInfo::SETILSWIM)
32750 3340 ilswim = true;
32751
32752
1/2
✓ Branch 0 taken 9888056 times.
✗ Branch 1 not taken.
9888056 if(flags & WalkflagInfo::CLEARCHARGEATTACK)
32753 {
32754 charging = 0;
32755 attackclk = 0;
32756 }
32757
32758
1/2
✓ Branch 0 taken 9888056 times.
✗ Branch 1 not taken.
9888056 if(flags & WalkflagInfo::SETDIR)
32759 {
32760 dir = info.getDir();
32761 }
32762
32763
2/2
✓ Branch 0 taken 9886768 times.
✓ Branch 1 taken 1288 times.
9888056 if(flags & WalkflagInfo::SETHOPCLK)
32764 {
32765 1288 hopclk = info.getHopClk();
32766 1288 }
32767
32768
2/2
✓ Branch 0 taken 9886612 times.
✓ Branch 1 taken 1444 times.
9888056 if(flags & WalkflagInfo::SETHOPDIR)
32769 {
32770 1444 hopdir = info.getHopDir();
32771 1444 }
32772
32773 9888056 }
32774
32775 17664894 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator ||(HeroClass::WalkflagInfo other)
32776 {
32777 17664894 HeroClass::WalkflagInfo ret;
32778 17664894 ret.newhopclk = newhopclk;
32779 17664894 ret.newdir = newdir;
32780
2/2
✓ Branch 0 taken 14672195 times.
✓ Branch 1 taken 2992699 times.
17664894 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
32781
32782 17664894 int32_t flags1 = (flags & ~UNWALKABLE) & (other.flags & ~UNWALKABLE);
32783 17664894 int32_t flags2 = (flags & UNWALKABLE) | (other.flags & UNWALKABLE);
32784 17664894 ret.flags = flags1 | flags2;
32785 17664894 return ret;
32786 }
32787
32788 211678 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator &&(HeroClass::WalkflagInfo other)
32789 {
32790 211678 HeroClass::WalkflagInfo ret;
32791 211678 ret.newhopclk = newhopclk;
32792 211678 ret.newdir = newdir;
32793
1/2
✓ Branch 0 taken 211678 times.
✗ Branch 1 not taken.
211678 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
32794
32795 211678 ret.flags = flags & other.flags;
32796 211678 return ret;
32797 }
32798
32799 211678 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator !()
32800 {
32801 211678 HeroClass::WalkflagInfo ret;
32802 211678 ret.newhopclk = newhopclk;
32803 211678 ret.newdir = newdir;
32804 211678 ret.newhopdir = newhopdir;
32805
32806 211678 ret.flags = flags ^ UNWALKABLE;
32807 211678 return ret;
32808 }
32809
32810 void HeroClass::explode(int32_t type)
32811 {
32812 static int32_t tempx, tempy;
32813 static byte herotilebuf[256];
32814 int32_t ltile=0;
32815 int32_t lflip=0;
32816 bool shieldModify=true;
32817 unpack_tile(newtilebuf, tile, flip, true);
32818 memcpy(herotilebuf, unpackbuf, 256);
32819 tempx=Hero.getX();
32820 tempy=Hero.getY();
32821 for(int32_t i=0; i<16; ++i)
32822 {
32823 for(int32_t j=0; j<16; ++j)
32824 {
32825 if(herotilebuf[i*16+j])
32826 {
32827 if(type==0) // Twilight
32828 {
32829 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 0, 0, (zc_oldrand()%8)+i*4));
32830 int32_t k=particles.Count()-1;
32831 particle *p = (particles.at(k));
32832 p->step=3;
32833 }
32834 else if(type ==1) // Sands of Hours
32835 {
32836 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 1, 2, (zc_oldrand()%16)+i*2));
32837 int32_t k=particles.Count()-1;
32838 particle *p = (particles.at(k));
32839 p->step=4;
32840
32841 if(zc_oldrand()%10 < 2)
32842 {
32843 p->color=1;
32844 p->cset=0;
32845 }
32846 }
32847 else
32848 {
32849 particles.add(new pDivineEscapeDust(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 6, herotilebuf[i*16+j], zc_oldrand()%96));
32850
32851 int32_t k=particles.Count()-1;
32852 particle *p = (particles.at(k));
32853 p->angular=true;
32854 p->angle=zc_oldrand();
32855 p->step=(((double)j)/8);
32856 p->yofs=Hero.getYOfs();
32857 }
32858 }
32859 }
32860 }
32861 }
32862
32863 2224 void HeroClass::SetSwim()
32864 {
32865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2224 times.
2224 if (CanSideSwim())
32866 {
32867 if (action != sideswimattacking && action != attacking) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
32868 else {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
32869 if (get_qr(qr_SIDESWIMDIR) && spins <= 0 && dir != left && dir != right) dir = sideswimdir;
32870 }
32871 2224 else {action=swimming; FFCore.setHeroAction(swimming);}
32872 2224 }
32873
32874 122945 void HeroClass::SetAttack()
32875 {
32876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 122945 times.
122945 if (IsSideSwim()) {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
32877 122945 else {action=attacking; FFCore.setHeroAction(attacking);}
32878 122945 }
32879
32880 134804361 bool HeroClass::IsSideSwim()
32881 {
32882
6/12
✓ Branch 0 taken 134804361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 134804361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 134804361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 134804361 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 134804361 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 134804361 times.
134804361 return (action==sideswimming || action==sideswimhit || action == sideswimattacking || action == sidewaterhold1 || action == sidewaterhold2 || action == sideswimcasting || action == sideswimfreeze);
32883 }
32884
32885 2774061 bool HeroClass::CanSideSwim()
32886 {
32887
1/2
✓ Branch 0 taken 2774061 times.
✗ Branch 1 not taken.
2774061 return (isSideViewHero() && get_qr(qr_SIDESWIM));
32888 }
32889
32890 12785348 int32_t HeroClass::getTileModifier()
32891 {
32892 12785348 return item_tile_mod() + bunny_tile_mod();
32893 }
32894 void HeroClass::setImmortal(int32_t nimmortal)
32895 {
32896 immortal = nimmortal;
32897 }
32898 void HeroClass::kill(bool bypassFairy)
32899 {
32900 dying_flags = DYING_FORCED | (bypassFairy ? DYING_NOREV : 0);
32901 }
32902 44183111 bool HeroClass::sideview_mode() const
32903 {
32904
3/4
✓ Branch 0 taken 773475 times.
✓ Branch 1 taken 43409636 times.
✓ Branch 2 taken 773475 times.
✗ Branch 3 not taken.
44183111 return isSideViewHero() && (moveflags & move_obeys_grav) && !toogam;
32905 }
32906 18082 bool HeroClass::is_unpushable() const
32907 {
32908 18082 return toogam;
32909 }
32910